D
dhtml
Array.splice({})
What should it do?
I think it should return a new Array with length 0.
Array.splice(arr, start, deleteCount [, item1 [, item2[,...]]])
http://bclary.com/2004/11/07/#a-15.4.4.12
Example:
Array.splice({})
Result:
FF3.1
function splice() { [native code] }
Webkit:
undefined
If - start - is passed in, a 0 length array is returned.
Array.prototype.splice.call(0, undefined);
Result: []
The methods that go into calculating the - length - property all call
ToNumber, either through ToUint32, or ToInteger. ToNumber coverts
undefined to NaN, which returns the value back to its caller, either
ToInteger or ToUint32, which converts NaN to +0.
It seems step 4 is not what I expect:
| 4. Call ToInteger(start).
start is omitted from the argument list, I assume this means start =
undefined.
ToInteger calls ToNumber.
ToInteger:
| 1. Call ToNumber on the input argument.
| 2. If Result(1) is NaN, return +0.
....
ToNumber returns NaN:
| 9.3 ToNumber
| The operator ToNumber converts its argument
| to a value of type Number according to the following table:
|-----------+-----+
| Undefined | NaN |
`....-------+-----+
Back to ToInteger, step 2.
| 2. If Result(1) is NaN, return +0.
What should it do?
I think it should return a new Array with length 0.
Array.splice(arr, start, deleteCount [, item1 [, item2[,...]]])
http://bclary.com/2004/11/07/#a-15.4.4.12
Example:
Array.splice({})
Result:
FF3.1
function splice() { [native code] }
Webkit:
undefined
If - start - is passed in, a 0 length array is returned.
Array.prototype.splice.call(0, undefined);
Result: []
The methods that go into calculating the - length - property all call
ToNumber, either through ToUint32, or ToInteger. ToNumber coverts
undefined to NaN, which returns the value back to its caller, either
ToInteger or ToUint32, which converts NaN to +0.
It seems step 4 is not what I expect:
| 4. Call ToInteger(start).
start is omitted from the argument list, I assume this means start =
undefined.
ToInteger calls ToNumber.
ToInteger:
| 1. Call ToNumber on the input argument.
| 2. If Result(1) is NaN, return +0.
....
ToNumber returns NaN:
| 9.3 ToNumber
| The operator ToNumber converts its argument
| to a value of type Number according to the following table:
|-----------+-----+
| Undefined | NaN |
`....-------+-----+
Back to ToInteger, step 2.
| 2. If Result(1) is NaN, return +0.