We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.
Required fields*
5
@Bergi thank you for your comment. I have corrected my answer. In my defense I can say that currently (as of v.0.10.18) official Node.js documentation says nothing about undefined as a member of global. Also neither console.log(global); nor for (var key in global) { ... } doesn't show undefined as a member of global. But test like 'undefined' in global show the opposite.
Regarding Minuses of typeof obj.prop == 'undefined', this can be avoided by writing as typeof obj.prop == typeof undefined. This also gives a very nice symmetry.
When we are true to the question headline „Detecting an undefined property", not true to the (different and much easier) question in the first sentence („check if undefined..."), you answer if ('foo' in o)... your answer is truly the first correct answer here. Pretty much everybody else just answers that sentence.
A tag is a keyword or label that categorizes your question with other, similar questions. Choose one or more (up to 5) tags that will help answerers to find and interpret your question.
complete the sentence: my question is about...
use tags that describe things or concepts that are essential, not incidental to your question
undefinedas a member ofglobal. Also neitherconsole.log(global);norfor (var key in global) { ... }doesn't show undefined as a member of global. But test like'undefined' in globalshow the opposite.[[Enumerable]]is false :-)Minuses of typeof obj.prop == 'undefined', this can be avoided by writing astypeof obj.prop == typeof undefined. This also gives a very nice symmetry.obj.prop === undefined.if ('foo' in o)... your answer is truly the first correct answer here. Pretty much everybody else just answers that sentence.