by nothrabannosir · 8y ago · 0 comments
Make sure you understand these, in order:
1. callbacks
2. promises
3. async await
And in the mean time :
1. prototype chain
2. classes
Understand them in their old school form, first. The reason being: this fancy new async await and classes stuff is just syntactic sugar, which hides the implementation and will confuse the hell out of you. You will not in a million years understand why you can
return someAsyncFunc();
Instead of: return await someAsyncFunc();
... from within an async func, unless it’s within a try { } !But if you understand promises, and how async await is just the same stuff different smell, you’ll immediately grok it.
And god have mercy on your soul if you try to debug code with classes and methods, without knowing about the prototype chain.
JavaScript is, at its core, an incredibly simple language. But es6 introduced a lot of smoke and mirrors, which only really makes sense once you understand precisely the things they’re trying to hide. You can get by , ignoring it, but there lies endless frustration.
It shouldn’t take long to get the basics. Invest the week, and proceed to use the more powerful tools with open eyes.
(And typescript and jsx will also confuse the hell out of you if you don’t get JavaScript yet. It’s so confusing and layered; make sure you start at the bottom!)
That’d be my advice. But I’m a very “depth first search” kind of guy :)
And just a reminder. JavaScript isn't a subset of React. If you want to learn JavaScript start by writing JavaScript. Then when you get that down, layer on a framework or two.
This should really be like the first point of every javascript tutorial ever. Honestly.
I don’t think there’s value in teaching a beginner about the prototype chain. It’s kind of obsolete knowledge at this point. ES6 classes work great, and will be very familiar to people coming from other languages.
I mean.. if someone was a beginner in Python would you first teach them about the metaclass system? (I wouldn’t)