JavaScript typeof operator

typeof vs ==

It sounds strange but most of the web developers still use == operator to check the ‘undefined’ value of a JavaScript variable. Don’t know why but however there’s typeof operator and I strongly recommend it for that purpose.

It simply should be:

typeof variable == ‘undefined’

One thought on “JavaScript typeof operator

Leave a Reply

Your email address will not be published. Required fields are marked *