Q:

js if not undefined

if (typeof myVar !== "undefined") {
    console.log("myVar is DEFINED");
}
13
if(myVar === null) {
	console.log("Element is undefined");
}
8
if (typeof myVariable === 'undefined'){
    //myVariable is undefined
}
9
if(typeof comment === 'undefined') {

  alert('Variable "comment" is undefined.');

} else if(comment === null){

  alert('Variable "comment" is null.');

}
5
let id;

if(typeof id === 'undefined') {
    console.log("id is undefined...");
}
1
let foo = undefined
//will return true
typeof foo === 'undefined'
1
javascript check number against undefined
0

New to Communities?

Join the community