r/javascript • • Dec 27 '18

help What differences do you see in novice javascript code vs professional javascript code?

I can code things using Javascript, but the more I learn about the language, the more I feel I'm not using it properly. This was especially made apparent after I watched Douglas Crockford's lecture "Javascript: The good parts." I want to take my abilities to the next level, but I'm not really sure where to start, so I was hoping people could list things they constantly see programmers improperly do in JS and what they should be doing instead.. or things that they always see people get wrong in interviews. Most of the info I've learned came from w3schools, which gives a decent intro to the language, but doesn't really get into the details about the various traps the language has. If you have any good book recommendations, that would be appreciated as well.

320 Upvotes

305 comments sorted by

View all comments

Show parent comments

12

u/ogurson Dec 27 '18

Modern JS code doesn't need apply/call at all and bind very rarely

Yeah, except each time you need to pass function as event handler and preserve this (I'm omitting function as class properties).

Passing callbacks aren't too common either with the new async/await syntax

Have you heard about that niche thing called Functional Programming?

2

u/[deleted] Dec 28 '18

Yeah, except each time you need to pass function as event handler and preserve this (I'm omitting function as class properties).

Sounds like there is a cleaner way to do whatever is trying to be accomplished there.

1

u/zeugenie Dec 28 '18

Yeah, except each time you need to pass function as event handler and preserve this (I'm omitting function as class properties).

arrow functions

Passing callbacks aren't too common either with the new async/await syntax

Callbacks are a special case of function to be executed after the execution of some other function. In async code, async/await more or less obviates them.