Skip to content

Instantly share code, notes, and snippets.

@josephhhhh
Last active March 15, 2018 13:02
Show Gist options
  • Save josephhhhh/0b396ef5609ee2e13c4057f81eb5b9b2 to your computer and use it in GitHub Desktop.
Save josephhhhh/0b396ef5609ee2e13c4057f81eb5b9b2 to your computer and use it in GitHub Desktop.
// original src:
// https://github.com/tc39/test262/blob/master/test/built-ins/Array/prototype/reverse/S15.4.4.8_A4_T1.js
TypedArray.prototype[1] = 1;
var x = [0];
x.length = 2;
x.reverse = TypedArray.prototype.reverse;
assert(
compareArray(x.reverse(), [1, 0])
);
x.length = 0;
assert(
compareArray(x.reverse(), [undefined, 1])
);
//////
Object.prototype[1] = 1;
Object.prototype.length = 2;
Object.prototype.reverse = TypedArray.prototype.reverse;
x = {0:0};
x.reverse = TypedArray.prototype.reverse;
assert(
compareArray(x.reverse(), [1, 0])
);
delete x[0];
delete x[1];
assert(
compareArray(x.reverse(), [undefined, 1])
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment