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
//* Type Inference *// | |
// The system can guess that array will contain only numbers | |
// based on the array's initialization. | |
const arr1 = [14, 21, 28]; | |
arr1.push(15); | |
arr1.push("Hello World!"); | |
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
const arr1 = [1, 2, 3]; | |
const arr2 = []; | |
if (arr1) { | |
console.log("You should see this message!"); | |
} | |
if (arr1.length) { | |
console.log("Array is not empty!"); |
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 students = []; | |
//** if(students) **// | |
// 1. students | |
// 2. Boolean(students) | |
if (true) console.log("You can see this message!"); | |
//** if(students == true) **// | |
// 1. "" == true |
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 students = []; | |
if (students) { | |
console.log("You can see this message!"); | |
} | |
if (students == true) { | |
console.log("You can't see this message!"); | |
} |
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 arr1 = []; | |
var arr2 = []; | |
//1. arr1 != arr2 | |
//2. (!(arr1 == arr2)) | |
//3. (!(false)) | |
if (true) console.log("It's true again!"); |
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 arr1 = []; | |
var arr2 = []; | |
//1. arr1 == !arr2 | |
//2. [] == false | |
//3. "" == false | |
//4. "" == 0 | |
//5. 0 == 0 | |
//6. 0 === 0 |
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 arr1 = []; | |
var arr2 = []; | |
if (arr1 == !arr2) { | |
console.log("Yes, it's true!"); | |
} | |
if (arr1 != arr2) { | |
console.log("It's true again!"); |
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 str1 = "Hello"; | |
var str2 = new String("Hello"); | |
str1 == str2 // true | |
str1 === str2 // false - coercion was not allowed this time |
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
// 1. compare number == array | |
// 2. 42 == ToPrimitive(array) | |
// 3. 42 == "42" | |
// 4. 42 === 42 | |
if (true) console.log("Now you know the magic!"); |
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 number = 42; | |
var array = [42]; | |
if (number == array) console.log("It works. Is this a magic?"); |
NewerOlder