Could somebody explain to me the difference between if(obj.x == undefined) and if(typeof obj.x == 'undefined')
In some context the first one works fine, but in other I need to use the second way.
Questions
1 – What is the difference between the two condition?
2 – Is there a best practice?
The best practice is to not just check the truthiness but the strict equality
example
this use to be an issue because
undefined(a global property) use to be writable, as of 1.8.5 is is non-writable, providing you with a secure comparison in ES5 spec environments.per MDN