Actually, that definition is a bit confusing.
The instanceof operator does not actually check whether an object was created by a constructor function. It checks whether it inherits from the constructor prototype (the inheritance need not be direct).
The difference is subtle, but important. Let me elaborate:
Imagine that we have two constructors, and both have the same prototype:
var F = function() {};
var G = function() {};
var FakeConstructor = function() { this.name = "FakeConstructor"; };
var obj = {};
F.prototype = obj;
G.prototype = obj;
// F prototype and G prototype are the very same object. We set the constructor to FakeConstructor just to point out that it is irrelevant for the instanceof operator
G.prototype.constructor = FakeConstructor;
var g = new G();
var f = new F();
f instanceof F;// true
f instanceof G;// true
g instanceof F;// true
g instanceof G;// true
Even though f
and g
have been constructed using different constructors, both are considered instances of F
and G
. The reason is F
and G
both have the same prototype.
So, is the constructor useful in any sense?
- It could be thought of as the "public identity" of the class (as you can see, instanceof reinforces this fact) though prototypes are the fundamental identity.
- Can be used as a reference to the constructor function that created the object (though you'd have to be careful and set it up correctly).
Apart from those two, no more uses come to mind.
Why all of this relates to my problem?
As pointed out in other answers, Array() is the constructor of [] and the prototype is non-writable so you're not going to have any problem performing that check in the same window/frame.
However, there's a caveat. If your webapp uses more than one window or frame you have to take into account that each window or frame is a distinct execution context, and each has its own global object and its own set of constructor functions. Two arrays created in two different frames inherit from two identical but distinct prototype objects, and an array created in one frame is not instanceof the Array() constructor of another frame.