News for hackers. Stuff that matters.
Re:Show HN: The JavaScript Way, a book for learning modern J... by jchien17 on Thursday July 27, 2017 @08:24PM (#14870978)
Should one learn ES2015 before learning ES5? Is there any value or need to learn ES5 if you're not maintaining an old codebase?
Re:Show HN: The JavaScript Way, a book for learning modern J... by z3t4 on Friday July 28, 2017 @03:35AM (#14872631)
It's the same language. ES2015 is just syntax "sugar" for doing the same thing, it's mostly opinionated and for convenience. So I suggest both looking at the old style and the new style and write your code in a way that make most sense to you! Then when you join a company, there will be style guides and "linters" to enforce it. But if you have to choose, start with the old style because that's how JavaScript have been looking like for 15 years and a lot of code looks like that. Also I'm not a big fan of "trans-pilers".
Re:Show HN: The JavaScript Way, a book for learning modern J... by beeandapenguin on Friday July 28, 2017 @11:26AM (#14874913)
If they are writing in Node, I'd say there's no need to learn ES5 as they should be using a node version with LTS. If they are writing JS in the browser? Then yes, they should learn ES5 as it's quite likely they will be debugging transpiled code at some point.
Re:Show HN: The JavaScript Way, a book for learning modern J... by pspeter3 on Thursday July 27, 2017 @08:37PM (#14871016)
Not all browsers support ES2015 so knowing ES5 first is helpful.
Re:Show HN: The JavaScript Way, a book for learning modern J... by nailer on Friday July 28, 2017 @07:29AM (#14873447)
All current browsers support ES2017.

If supporting IE or out of date mobile devices is worth your time (it might be, it might not be - consider CSS grid won't work, flexbox won't work, webcrypto won't work, HTML5 clipboard won't work, and you'll need double the time to deal with them and their awful devtools) transpiling is a good option.

Re:Show HN: The JavaScript Way, a book for learning modern J... by EduardoBautista on Thursday July 27, 2017 @08:41PM (#14871031)
Except on almost any serious project you should be using a transpiler anyways.
Re:Show HN: The JavaScript Way, a book for learning modern J... by pspeter3 on Thursday July 27, 2017 @09:26PM (#14871205)
Agreed, but I find it helpful to understand the transpiled code. The "clean" ES5 output was a large reason for using TypeScript https://blog.asana.com/2014/11/asana-switching-typescript/
Re:Show HN: The JavaScript Way, a book for learning modern J... by jeremy_wiebe on Friday July 28, 2017 @12:17AM (#14871926)
I agree to an extent, but any modern transpired should also emit source maps which should shield most people from needing to look st or understand the "low level" generated code.
Re:Show HN: The JavaScript Way, a book for learning modern J... by nawtacawp on Thursday July 27, 2017 @09:05PM (#14871115)
transpiler?
Re:Show HN: The JavaScript Way, a book for learning modern J... by tannhauser23 on Thursday July 27, 2017 @09:24PM (#14871197)
It converts your ES6 code into Javascript that can run on all browsers. It's how you can get advanced Javascript features before the browsers fully implement them. Look up Babel.
Re:Show HN: The JavaScript Way, a book for learning modern J... by yunyu on Thursday July 27, 2017 @09:23PM (#14871194)
Converts modern JavaScript to ES5
Re:Show HN: The JavaScript Way, a book for learning modern J... by tasty_freeze on Thursday July 27, 2017 @10:34PM (#14871492)
It is a portmanteau of translater + compiler