Check for undefined var


/ Published in: JavaScript
Save to your folder(s)

You can use if(!myVar) which will return True if a variable is undefined OR zero, but this method specifically checks for undefined.


Copy this code and paste it in your HTML
  1. if(typeof(myVar) == "undefined")

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.