Shakhzod Tojiyev
shakhzodtojiyev

shakhzodtojiyev

Create your own Array Methods | JavaScript ES6 Guide - how to implement Map, Filter, Reduce

Create your own Array Methods | JavaScript ES6 Guide - how to implement Map, Filter, Reduce

Shakhzod Tojiyev's photo
Shakhzod Tojiyev
·Sep 29, 2021·

1 min read

You Tube: Simon Høiberg

Learn more...

Article: How To Implement JavaScript Array Methods From Scratch

Article: How to implement every JavaScript array method

Example:

const myCustomMapFunction = function() {
    return this.map(e => e * 2)
}

Array.prototype.mul = myCustomMapFunction;

const arr = [1, 2, 3];

console.log(arr.mul());    // [2, 4, 6]
 
Share this