Skip to content

Instantly share code, notes, and snippets.

@iamsaief
Created August 22, 2020 10:30
Show Gist options
  • Save iamsaief/fc216f355d460c0dab74e1d56d226586 to your computer and use it in GitHub Desktop.
Save iamsaief/fc216f355d460c0dab74e1d56d226586 to your computer and use it in GitHub Desktop.
/* 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