DEV Community

Discussion on: 8 JavaScript Tips & Tricks That No One Teaches πŸš€

Collapse
 
strativd profile image
Strat Barrett

On that note – which I completely agree with – it's interesting how readable this is Array.from(dogs) compared to dogs.map() if map wasn't so widely adopted :)

Collapse
 
arealsamurai profile image
An actual, Real Samurai • Edited

On that note, I'd love to see how performant Array.from() is compared to .map() that I know doesn't perform very well

Thread Thread
 
killshot13 profile image
Michael R.

Now you've inspired a more ambitious project. Building a custom standalone performance measurement tool for Javascript.

It could be something similar to Runkit, but strictly for benchmarking the various methods and approaches to the same end goal. Like which is faster?

capsLockNames = names.map(capitalize)
Enter fullscreen mode Exit fullscreen mode

OR

capsLockNames= []
for x = 0; x < names.length; x++
  capsLockNames[x] = capitalize(names[x]))
Enter fullscreen mode Exit fullscreen mode

πŸ€”πŸ€”πŸ€”

Thread Thread
 
arealsamurai profile image
An actual, Real Samurai

I can tell you for sure that the for loop is way more performant than map. But if you do compare everything, I'm definitely interested to read.

Some comments have been hidden by the post's author - find out more