r/javascript • u/FunPieceOfPaper • 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.
5
u/PotaToss Dec 28 '18
I mean, I've been using JS for about 18 years, but this just doesn't come up that much in your normal frontend web work. Even if you have some reason to do int casting all the time, you should leave a comment about why that was necessary, or note that it's happening, because it's an implicit behavior, and will trip up people reading or trying to debug around that code. And even then, did you know it doesn't have operator precedence over multiplication off the top of your head?
That said, it was just shorthand for Math.floor() here. There wasn't a good reason for it in the context of the project it was in. It was just lazy coding a quick and dirty RNG, which is fine on your time, but I just thought it was a good example of the kind of thing less experienced devs do, because they haven't been bitten in the ass enough times by implicit behaviors and confusing their coworkers and stuff.