Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs

aal89

2
Posts
A member registered 73 days ago

Recent community posts

I came across this when reading this medium article: https://medium.com/@alexbeer/hi-nice-sum-up-of-different-duplicate-filters-eb4d3895fd14

(2 edits)

Kinda related, but something different.

You should reference the array you are looping through in the reduce method (or any other functional loop). Et voila, your loop is quicker. Don't even use the reference.

Examples:

// this one is quicker...
sum = data.reduce((acc, curr, i, arr) => {
    return acc + curr * curr
})
// than this one
sum = data.reduce((acc, curr) => {
    return acc + curr * curr
})

(am using Node 8)