Tag Archives: typeof

Does JavaScript undefined Equals undefined?

Weird JS

Does "undefined" equals "undefined"?
Does JavaScript "undefined" equals "undefined"?

As you know sometimes JavaScript can be weird. Let’s see the following example and let’s try to answer the question: does “undefined” equals “undefined”. What do I mean?

First take a look at the following code.

var a;
var b = undefined;
// alerts "false"
alert(b == a);

Both a and b are undefined, but they are NOT equal. Now let’s see where it can become a problem.

We have an object with one member variable that is not defined.

var f1 = function()
var obj1 = new f1();

Now you’d like to know whether the object “b” has the property “myvar”. There are lots of examples online, but what’s the right way?
Continue reading Does JavaScript undefined Equals undefined?

javascript: what is typeof typeof


If you’ve ever heard about typeof operator in javascript than, how about those few questions:

  1. what is typeof typeof ‘string’ ?
  2. what is typeof typeof?


The first one is “string”. Yes if there you have the following code:

typeof something_undefined

that gives of course undefined, but if there is typeof typeof something_undefined the answer is string, because “udefined” itself is a string.

The second question is simple javascript error, there is no case with typeof typeof only.