function ArraySplice(start, delete_count) {
var num_arguments = %_ArgumentsLength();
- // SpiderMonkey and JSC return undefined in the case where no
- // arguments are given instead of using the implicit undefined
- // arguments. This does not follow ECMA-262, but we do the same for
- // compatibility.
- // TraceMonkey follows ECMA-262 though.
- if (num_arguments == 0) return;
-
var len = TO_UINT32(this.length);
var start_i = TO_INTEGER(start);
int n_arguments = args.length() - 1;
- // SpiderMonkey and JSC return undefined in the case where no
- // arguments are given instead of using the implicit undefined
- // arguments. This does not follow ECMA-262, but we do the same for
- // compatibility.
- // TraceMonkey follows ECMA-262 though.
+ // Return empty array when no arguments are supplied.
if (n_arguments == 0) {
- return Heap::undefined_value();
+ // No handle scope needed since we return directly.
+ return *Factory::NewJSArray(0);
}
int relative_start = 0;
(function() {
var array;
for (var i = 0; i < 7; i++) {
- // SpiderMonkey and JSC return undefined in the case where no
- // arguments are given instead of using the implicit undefined
- // arguments. This does not follow ECMA-262, but we do the same for
- // compatibility.
- // TraceMonkey follows ECMA-262 though.
array = [1, 2, 3]
- assertEquals(undefined, array.splice());
+ assertEquals([], array.splice());
assertEquals([1, 2, 3], array);
// SpiderMonkey, TraceMonkey and JSC treat the case where no delete count is
assertArrayEquals([], arr)
arr = ['a','b','c','d'];
-assertEquals(undefined, arr.splice())
+assertEquals([], arr.splice())
assertArrayEquals(['a','b','c','d'], arr);
assertArrayEquals(['a','b','c','d'], arr.splice(undefined))
assertArrayEquals([], arr);