according to ecma262-3 8.6.2.6 [DefaultValue]
http://bclary.com/2004/11/07/#a-8.6.2.6
now i want to get the [[DefaultValue]] of [ ]
so according to ecma,like this:
When the [[DefaultValue]] method of O is called with hint Number, the following steps are taken:
1. Call the [[Get]] method of object O with argument "valueOf".
[ ].valeOf() => [ ]//itself
2. If Result(1) is not an object, go to step 5.
[ ] is an object
3. Call the [[Call]] method of Result(1), with O as the this value and an empty argument list.
Result(1) => [ ],[ ] don't implement [[Call]]
4. If Result(3) is a primitive value, return Result(3).
so ,no Result(3),or it is still [ ]
5. Call the [[Get]] method of object O with argument "toString".
[ ].toString => ""
6. If Result(5) is not an object, go to step 9.
Result(5) => "" is not an object, go to step 9
7. Call the [[Call]] method of Result(5), with O as the this value and an empty argument list.
8. If Result(7) is a primitive value, return Result(7).
9. Throw a TypeError exception.
error? god!
相关问题
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- void before promise syntax
- Keeping track of variable instances
- Can php detect if javascript is on or not?
[[DefaultValue]]
called on array object eventually gets to (and calls) array object'stoString
method. That method is essentially anArray.prototype.toString
which is the same as callingArray.prototype.join
on an array object (see 15.4.4.2). SotoString
on an empty array object returns empty string (""
) which is a primitive value and is therefore returned from [[DefaultValue]] internal method.So [[DefaultValue]] of array is an empty string — if
Array.prototype.string
is not overwritten/shadowed, and ifArray.prototype.valueOf
is not overwritten/shadowed.