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>
16 lines
268 B
JavaScript
16 lines
268 B
JavaScript
var a = [1, 2, 3];
|
|
var v = a.shift();
|
|
console.log(v);
|
|
console.log(a.join(','));
|
|
console.log(a.length);
|
|
|
|
var b = [3, 4];
|
|
var len = b.unshift(1, 2);
|
|
console.log(len);
|
|
console.log(b.join(','));
|
|
|
|
var c = [];
|
|
console.log(c.shift());
|
|
c.unshift(1);
|
|
console.log(c.join(','));
|