|
|
|
|
|
by Joeri
5173 days ago
|
|
The "Object.prototype.toString.call" solution is guaranteed to work according to ECMA-262, and will only return true for a real Array instance (not something masquerading as an Array): Object.prototype.toString ( )
When the toString method is called, the following steps are taken: 1. If the this value is undefined, return "[object Undefined]". 2. If the this value is null, return "[object Null]". 3. Let O be the result of calling ToObject passing the this value as the argument. 4. Let class be the value of the [[Class]] internal property of O. 5. Return the String value that is the result of concatenating the three Strings "[object ", class, and "]". |
|
This is because there is no defined standard for `toString` results of host objects.