let users = [
{ name: "Peter", age: 25 },
{ name: "Sonya", age: 18 },
{ name: "Huanita", age: 19 }
];
if( typeof Object.prototype.Map !== 'function' ) {
Array.prototype.Map = function( fn ) {
if( fn && Object.prototype.toString.call( fn ) === '[object Function]' ) {
arr = [];
for( var i = 0; i < this.length; i++ )
arr.push( fn( this[ i ], i, this ));
return arr;
}
};
}
let result = users.Map(( el ) => el.name );
result[ 3 ] = "Tanya";
console.log( result );
https://jsfiddle.net/b5xaume4/
https://jsfiddle.net/b5xaume4/
https://jsfiddle.net/b5xaume4/
По той причине чтобы понять, почему мой код не работает и как взаимодействовать с переменной accumulator = [ ] как с массивом