Created
August 22, 2020 10:30
-
-
Save iamsaief/fc216f355d460c0dab74e1d56d226586 to your computer and use it in GitHub Desktop.
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
/* unassigned variable */ | |
let name; | |
console.log(name); | |
// Output: undefined | |
/* No return/ nothing after return */ | |
function add(num1, num2) { | |
result = num1 + num2; | |
return; | |
} | |
result = add(10, 30); | |
console.log(result); | |
// Output: undefined | |
/* passing incorrect parameter */ | |
function add(num1, num2) { | |
console.log(num1, num2); | |
} | |
result = add(); | |
// Output: undefined | |
/* passing incorrect parameter */ | |
function add(num1, num2) { | |
console.log(num1 + num2); | |
} | |
result = add(); | |
// Output: NaN; | |
/* Accessing non-existing index/property */ | |
const userData = { | |
name: "Jhon Doe", | |
phone: "123263", | |
}; | |
console.log(userData.id); | |
// Output: undefined | |
userData.address = undefined; | |
console.log(userData.address); | |
// Output: undefined |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment