Wire arrays into the prototype chain (Array.prototype → Object.prototype), add the Array global with isArray(), and implement callback-based methods (map, forEach, filter, find, findIndex, some, every, reduce, reduceRight, sort) plus simple methods (includes, lastIndexOf, reverse, shift, unshift). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
10 lines
158 B
JavaScript
10 lines
158 B
JavaScript
var a = [1, 2, 3, 4, 5];
|
|
a.reverse();
|
|
console.log(a.join(','));
|
|
var b = [];
|
|
b.reverse();
|
|
console.log(b.length);
|
|
var c = [42];
|
|
c.reverse();
|
|
console.log(c[0]);
|