Hacker News new | past | comments | ask | show | jobs | submit login

Use Typescript. Use async/await. Use ES6 classes, don’t do the other class-like patterns. Oh and use ES6 features in general, like fat arrows. And don’t write “var”.

Don’t use unnecessary compile-to-js syntaxes like Coffeescript since they will just be a burden in the long run. TS and JSX is an exception, those are worth it.

Don’t write “undefined” in your code, just write “null”, and treat those values the same. Some programmers will assign different meanings to “undefined” versus “null” but usually these meanings are arbitrary and silly. In most situations you don’t even need one kind of null, let alone two.




I advise the opposite of these points. Start with es5, at least for a few days. Go through the old tutorials, especially for promises.

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 :)


Fully agree. Start with the old school basics.

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.


If you want to learn JavaScript start by writing JavaScript.

This should really be like the first point of every javascript tutorial ever. Honestly.


Yeah, I agree there’s value to learning and using Promises before async/await, since you often need to think in terms of promise vales when using async.

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)


Except that ES6 "classes" don't have class attributes, because... they're really prototypes.


Unless you're very much supporting very legacy stuff, don't bother learning about prototypes, at least beyond "well it makes objects but unlike classes its actually a function itself" stuff.


Thank you for reply which is clear and actionable!


Isnt it too early for going ES6 only?

For learning sure, but for production I still think best to go ES5 ...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: