ways to check if a variable is undefined in javascript

var x;

1. x === undefined  (returns true)

2. typeof x == ‘undefined’ (returns true)

3. !x (returns true)

4. x == void 0 (returns true, not a good idea though because it is hard to understand)

4. if you have a variable x, when its value is undefined but typeof x returns ‘string’ and x === undefined returns false, then try x == ‘undefined’. 🙂