javascript check for undefined

47

javascript if undefined -

if(typeof comment === 'undefined') {

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

} else if(comment === null){

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

}

js test undefined -

if (typeof something != "undefined") {
    // ...
}

Comments

Submit
0 Comments