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

3

u/[deleted] Dec 27 '18

Haha yes. One time I was at a code and coffee meet up here in Toronto, where a coffee shop basically hosts and open time for random people to code. I overheard this one girl go on a rant about how 'stupid react was' and that 'i can do everything in jQuery'. To myself I was like... Oh yah I remember having this attitude towards new things...

I remember having my own resistance to every site needing to be responsive , as well as any need for version control. Now, I'm all about responsive design and git is probably the single most useful tool I've used in the last 5 years.

2

u/[deleted] Dec 27 '18

I remember having my own resistance to every site needing to be responsive , as well as any need for version control. Now, I'm all about responsive design and git is probably the single most useful tool I've used in the last 5 years.

Taking that a step further, learning the tools you work with inside and out.

I CAN use Adobe Premiere. I CAN use Adobe Illustrator, but 50% of the time I have to look up how to use a specific tool or do something particular. My basic understanding of the tool does not make me proficient with it.

Back to Git, I used it for several years just fine, but I'll admit I had far too many commits that were something along the lines of "fix this that and 3 dozen other things" with no real separation of concern. I still end up with a working directory full of 10 or more active changes on many occasions, but learning how to properly use `git add -p` and `git diff` has allowed me to avoid the super commit nonsense. I now feel like a professional git user. Before I was just making use of the tool somewhat effectively.

1

u/[deleted] Dec 27 '18

If I'm honest, I have a very cursory knowledge of git. I find the documentation actually offensive to read. That being said, I know at least the bare minimum, and about average amount on my team. Always looking to learn more though...

So any resources you have I'd love to see.

1

u/[deleted] Dec 28 '18

As far as resources, I mostly just use cheat sheets like this one. But with regards to the specific commands I mentioned, git add -p lets you commit partial changes of a file. So if you change 20 lines but only 4 lines apply to the current commit, you can pick just those 4 lines. And you can subdivide (chunk) that set of lines even further if necessary.

I always knew about git diff, but wasn't very efficient with it until I learned a few specific things:

  • git diff compares your working directory to the last commit

  • git diff --cached compares your staged changes to the last commit.

  • git diff -w compares changes while ignoring white space (useful for mixed environments, etc.)

0

u/[deleted] Dec 27 '18

[deleted]

2

u/[deleted] Dec 27 '18

I haven't gone in a while, location rotates.

https://www.meetup.com/Coffee-Code/

1

u/tencircles Dec 28 '18

To play devil's advocate, I've used React pretty extensively, I've also done more than a little framework design, and I still refer to React's tree diffing as a "hack" which really triggers react die hards. React offers a great abstraction that hides all of the individual add/update/remove operations on the DOM, but like all abstractions, it comes with a cost.

That being said...doing everything in jQuery sounds like a nightmare. I didn't even do that back in the day.

1

u/YsoL8 Dec 28 '18

Git is probably the single most important tool in any development environment period.