This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log(9/81); // divides 9 by 81 results to 0.1111111111111111 | |
console.log((9/81).toFixed(2)); // applying toFixed(2) results to 0.11 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log(9/81); // divides 9 by 81 results to 0.1111111111111111 | |
console.log((9/81).toFixed(2)); // applying toFixed(2) results to 0.11 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log(9/81); // divides 9 by 81 results to 0.1111111111111111 | |
console.log((9/81).toFixed(2)); // applying toFixed(2) results to 0.11 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log(2.998e8); // means 2.988 * 10 to the power of 8 or equal to 2.998 *10^8 = 299,800,000 | |
console.log(3e2); // same as above, means 3*(10^2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Durant = 35+"Durant"; // concatenate number and String, return value will be type of string | |
console.log(typeof Durant); // returns string | |
var NumBoolean = 5+true; // adds 1, returns 6 type of number | |
console.log(typeof NumBoolean); // returns number | |
console.log(14%5); // returns the remainder 4 | |
console.log(2**3); // returns 8, same as 2*2*2 | |
var x = 5; // x = 5 | |
var y = ++x; // y = 6 | |
var z = 5+5-2*8/2; // z =2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log("I am Glendon.\nAuthor of this blog"); | |
//I am Glendon. | |
//Author of this blog |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log('It\'s hard to say goodbye'); // It's hard to say goodbye | |
console.log('he'+'llo'); // hello |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log(typeof 9); // typeof is a unary operator, this code logs "number" in the console | |
console.log(2+2); // addition is an example of a binary operator, requires two numbers, before and after the addition operator | |
console.log(true ? 1 : 2); // returns the value before the colon if true, in this sample, 1 | |
console.log(false ? 1 : 2); // if false, return the value after the colon |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (false) | |
if (null) | |
if (undefined) | |
if (0) | |
if (NaN) | |
if ('') | |
if ("") | |
if (document.all) [1] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log(9>8); // true | |
console.log(9>=8); // true | |
console.log(9!==8); // true, use two equal sign when you need to use strict equalitiy |
OlderNewer