Comment

Comment by drinchev

Some more practical examples

    // Grab unique
    [1,1,2,3,4].filter( ( item, index, array ) => array.indexOf( item ) === index )
    // => [1,2,3,4] 

    // Flatten
    [[1,2],[3,4]].reduce( ( result, item ) => result.concat(item), [] );
    // => [1,2,3,4]
Not sure why the author missed `sort`.

    // Sort
    [1,2,4,3].sort( ( a, b ) => a - b )
parent drinchev 9 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton