Javascript Array flatMap() method

Description

Javascript Array flatMap() method


Array.prototype.flatMap = flatMap;
module.exports = flatMap;/*from w ww  .  j  a  v a  2 s. c  o  m*/

function flatMap () {
    return this.reduce(function (p, c) {
        if (!c) return p;
        return p.concat(c);
    }, []);
}



PreviousNext

Related