The problem is that undefined compared to null using == gives true. The common check for undefined is therefore done like this:
typeof x == "undefined"
this ensures the type of the variable is really undefined.
Answer from Wolfram Kriesing on Stack Overflowundefined
adjective
- Lacking a definition or value
- (mathematics) That does not have a meaning and is thus not assigned an interpretation
Videos
The problem is that undefined compared to null using == gives true. The common check for undefined is therefore done like this:
typeof x == "undefined"
this ensures the type of the variable is really undefined.
It turns out that you can set window.undefined to whatever you want, and so get object.x !== undefined when object.x is the real undefined. In my case I inadvertently set undefined to null.
The easiest way to see this happen is:
window.undefined = null;
alert(window.xyzw === undefined); // shows false
Of course, this is not likely to happen. In my case the bug was a little more subtle, and was equivalent to the following scenario.
var n = window.someName; // someName expected to be set but is actually undefined
window[n]=null; // I thought I was clearing the old value but was actually changing window.undefined to null
alert(window.xyzw === undefined); // shows false
Probably a trivial question, but it's been bugging me lately.
Most of us learn in school that 1÷0 is "undefined", but usually the teacher doesn't go much further than that. I've taken it to mean that dividing by zero is an operation that is not defined in standard mathematics, i.e. the answer to 1÷0 is not defined. However, I've seen people (both students and teachers) talk about "undefined" as though it's a mathmatecal term in of itself. Is this proper usage of the term, or does it simply mean that something is not defined?
tl;dr -- When discussing division by zero, is "undefined" a noun or an adjetive?