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>
11 lines
271 B
JavaScript
11 lines
271 B
JavaScript
var result = [];
|
|
[1, 2, 3].forEach(function(x) { result.push(x * 2); });
|
|
console.log(result.join(','));
|
|
|
|
var indices = [];
|
|
['a', 'b', 'c'].forEach(function(v, i) { indices.push(i); });
|
|
console.log(indices.join(','));
|
|
|
|
var r = [1].forEach(function(x) {});
|
|
console.log(r);
|