Dmitry A. Soshnikov wrote:
[...]
Yeah, but e.g. Google Chrome seems to distinguish real [undefined]
value and [not passed] parameter:
You can always distinguish them by checking `arguments.length` value of
course.
Ah, that's just theoretical interest for me, no more; sure it's Chorme
implementations bug of call/apply methods.
var getClass = Object.prototype.toString;
alert(getClass.call()); // [object Object]
Strange. I actually get "[object builtins]" here as well (Chrome 4.x on
Mac). Which version are you on?
I have Chrome v.3.0.195.27 (WinXP). Yep, there were some changes in
4.x version, e.g. they removed JS-code implementation of native
methods from .toString:
In v.4.x you'll get standard:
alert([].push);
Result: function push() {[native code]}
And in 3.x sort of:
alert([].push);
function push() {
var n = ToUint32(this.length);
var m = _ArgumentsLength();
for (var i = 0; i < m; i++) {
this[i+n] = _Arguments(i);
}
this.length = n + m;
return this.length;
}
alert(getClass.call(undefined)); // [object builtins]
alert(getClass.call(null)); // [object builtins]
Well this just makes their implementation non-conformant.
Yes, it's.
It looks like "builtins" is the [[Class]] of
`undefined` and `null`, or more likely [[Class]] of their internal
wrappers or something (that somehow get past `call`/`apply`'s primitive
coercion).
Yeah, kind of, on implementation level they have special namespace for
that Builtins:
...) where that entities are described.
[...]
Yep. However, `toString` from <Global object>'s [[Prototype]] actually
returns "[object DOMWindow]". Apparently this next object in Global
Object's prototype chain is `DOMWindow.prototype` (where DOMWindow
doesn't seem to be exposed publicly).
(function(){ return this.__proto__.constructor; })();
/* function DOMWindow() { [native code] } */
So the proto chain there is apparently something like:
<Global Object> --> DOMWindow.prototype --> <...> --> Object.prototype
Yes, seems so, but e.g. FF also has "additional" objects in prototype
chain of the global object (not global -> Object.prototype directly):
alert(this.__proto__); // [xpconnect wrapped native prototype]
alert(this.__proto__.__proto__); // [object Global Scope Polluter]
alert(this.__proto__.__proto__.__proto__); // [object Object] -
Object.prototype appears only now
alert(this.__proto__.__proto__.__proto__.__proto__); // null, end of
the chain - Object.prototype.[[Prototype]]
/ds