DEV Community

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

Collapse
 
devtalhaakbar profile image
Muhammad Talha Akbar • Edited

Great, Garvit! It's always great to know the language so well and bring about these unconventional ways to solve problems. However, it's always recommended to write code that is self-explanatory. And, I find majority of these tricks to be confusing (to an average eye). Use them when you really have to and leave a comment to make your intention clear.

Collapse
 
garvitmotwani profile image
Garvit Motwani

Noted! and thanks for reading the article!

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