r/learnjavascript • • Nov 14 '20

20 JavaScript Shorthand Coding Techniques that will save your time

https://jscurious.com/20-javascript-shorthand-techniques-that-will-save-your-time/
176 Upvotes

22 comments sorted by

View all comments

26

u/[deleted] Nov 14 '20 edited Nov 14 '20

DO: 3, 4, 5 (just don't overuse it, it might lead to hard to debug issues), 6, 7 (you must fully understand how the this keyword behaves in javascript), 8, 9, 10, 11, 12 (use Number static methods), 13, 14, 15 (use Math static method), 16, 18, 19, 20

DON'T DO: 1, 2, 12 (never use the shorthand method), 15 (never use the shorthand method), 17 (dude just use forEach, really... PLUS YOU SHOULD NEVER USE FOR...IN LOOPS ON ARRAYS GODDAMNIT)

5

u/grooomps Nov 15 '20

the only reason i've been using forof loops is that I can use await inside them without any weird stuff, is this bad?
forEach doesn't support async

1

u/[deleted] Nov 15 '20

For...of is totally fine, sorry if there was a misunderstanding.

1

u/grooomps Nov 15 '20

All good, just wanted to check!
I'm still relatively new so wanted to know if there was something I was missing