undefined value in JS
console.log(a)
/// ------- output
/// above code would trigger an error when the code runs
/// Uncaught Reference Error: a is not declaredvar a;
console.log('>>>>', a)
if (a === undefined) {
console.log('>>>> a has a value of undefined');
} else {
console.log('>>>> a has some defined value');
}
/// ------- output
/// above code would output below
/// >>>> undefined
/// >>>> a has a value of undefined
Last updated