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>
12 lines
333 B
JavaScript
12 lines
333 B
JavaScript
var doubled = [1, 2, 3].map(function(x) { return x * 2; });
|
|
console.log(doubled.join(','));
|
|
|
|
var indices = [10, 20, 30].map(function(v, i) { return i; });
|
|
console.log(indices.join(','));
|
|
|
|
var empty = [].map(function(x) { return x; });
|
|
console.log(empty.length);
|
|
|
|
var arrow = [1, 2, 3].map(x => x + 10);
|
|
console.log(arrow.join(','));
|