Detecting Undefined Variables in JavaScript

This pops up every so often so I thought I’d dedicate a post to it. JavaScript has no “isset” function. Instead, your best bet is to use the following:

if((typeof theVariable) == ‘undefined’)

Share this

  • Facebook
  • Reddit
  • StumbleUpon
  • Digg
  • email
  • del.icio.us
  • Twitter
  • LinkedIn

Leave a Reply