blob: d7eeef37eb0927b1685065faf8d32f2c3a3f2f33 [file] [log] [blame]
// author: Simon Zünd
let array = [undefined, 'c', /*hole*/, 'b', undefined, /*hole*/, 'a', 'd'];
Object.defineProperty(array, '2', {
get() { array.length = array.length - 2; return this.foo; },
set(v) { this.foo = v; }
});
debug('.sort():');
array.sort();
log(array);
array = [undefined, 'c', /*hole*/, 'b', undefined, /*hole*/, 'a', 'd'];
Object.defineProperty(array, '2', {
get() { return this.foo; },
set(v) { array.length = array.length - 2; this.foo = v; }
});
debug('.sort(comparator):');
array.sort((a, b) => a - b);
log(array);