JS Releases : ES5,ES6+ and ESNext
Now that you are familiar with the fundamentals of the JavaScript language, we need to talk about JavaScript versions or releases before moving on. We briefly talked about this in the intro lecture, but now let's go into more depth because it's really important to know how JavaScript releases work and how we can use them.
It's important for your work as a web developer and also because you will see these topics coming up in the developer community all the time. It will then be nice that you understand what's going on.
The best way to start understanding JavaScript versions; is by looking at the history of JavaScript. Let's start at the beginning of the internet itself.
Quickly after the internet was invented and the two first browsers developed, developers wanted to make websites more interactive. In other words, they needed a programming language for the browser.
In 1995, the Netscape Navigator, which by the time was the dominant browser, hired a guy named Brendan Eich to create the very first version of JavaScript in just ten days which was called Mocha, not JavaScript yet; but it already had many of the fundamental features that modern JavaScript has today.
In 1996, Mocha was renamed to LiveScript, which was then renamed to JavaScript for one simple reason: to attract developers from the hottest language at the time; Java. The Java in JavaScript was really just for marketing reasons because the language itself has nothing to do with Java.
Still, in 1996, Microsoft launched the Internet Explorer which copied JavaScript from NetsScape, but they called it JScript for legal reasons because you actually cannot just go and copy other people's programming languages.
What this means is that we now had two very similar but competing languages. Which of course, is never a good idea in the long term. With the internet growing so fast this time, people realized they needed to standardize JavaScript.
The language was then submitted to an independent standard organization called ECMA, which in 1997 released ECMScript 1 or ES1. This was the very first official standard of the JavaScript language. With this, every browser would now implement the same standard JavaScript.
Today, we usually use the term ECMAScript to refer to the standard, while JavaScript is used when we talk about the language in practice as it's implemented in browsers.
In 2009, after a lot of complications and disagreements about where the language should be headed, ES5 was released with a lot of great new features.
Six years later, the much-awaited new version of ES6 was launched in June 2015. This was the single biggest update to the language ever. As mentioned in the intro lecture, you will sometimes see ES6 being called ES2015, which is actually the official name.
The actual reason for ES6 being called ES2015 officially is that in 2015, ECMAScript changed to an annual release cycle, .i.e. there's going to be a new release every single year. The reason being they prefer to just add a small number of new features per year instead of releasing a huge new version every couple of years, as it happened with ES6. This way, it's going to be much easier for everyone to keep up to date.
According to this new annual release cycle, in 2016, ES2016 or ES7 was released, ES2017 in 2017, etc.
There is one particularity about JavaScript releases that is pretty unique for any programming language. That's backward compatibility all the way to ES1. Backward compatibility simply means that if you were to take some JavaScript code written in 1997 and put it in a modern browser, with a modern JavaScript engine today, it would still work just the same.
It works this way because of the fundamental principle that's baked into the JavaScript language and its development, which is to not break the web. This means that there is almost never anything removed from the language but only added in new versions. We cannot really call them new versions because they do not contain breaking changes like when other languages moved to new versions.
Instead, new versions are always just incremental updates, which add new stuff. So some people ( like me ) call them releases and not versions. The ECMA Script committee, which works on updating the language, does all this, so that old websites basically keep working forever. This idea and its principle of don't break the web obviously comes with problems because there are tons of old bugs and weird things in the language.
Remember that Brendan Eich made the very first version in 10 days, and back then, no one could ever imagine what JavaScript would be used for one day. Its initial goal ( JavaScript ) was just to add some simple dynamic to pages, not to write whole web applications like we do today.
These bugs and weird quirks in the language been giving the language a bad reputation amon many programmers who can't really take JavaScript serious because of this. We can actually go around many of these weird stuff by simply learning the modern JavaScript that matters today and just ignore most of the old weird stuff.
One more thing that we need to talk about again is forwards compatibility. It won't work if we ever tried to take JavaScript from the future 😆 and run today's modern JavaScript engine. Reason why we say that JavaScript is not forwards compatible.
To answer this question, we need to consider two different scenarios, development and production. The development phase is simply when you are building the site or application on your computer. To ensure you can use the latest JavaScript features in this phase, all you have to do is to use the most up-to-date version of the Google Chrome browser. This will ensure that everything you learn here works for you as well.
The second scenario, which is production refers to when your web application is finished, you deploy it on the internet, and it's then running in your users' browsers. This is where problems might appear because this is the part that we actually can't control. We cannot control which browser the user uses and can't assume our users use the latest browsers.
The solution to such a problem is to basically convert these modern JavaScript versions back to ES5 using a process called transpiling and also polyfilling. We will use a tool called Babel later in the course to transpile our code; but for now, we don't need that because I assume you are using the most up to date browser during development, whereas transpiling is only necessary after your app is developed and ready to be shipped to your users.
ES5 is fully supported in all browsers today, all the way down to Internet Explorer 9 from 2011. So it can be assumed that ES5 is safe to be used at this point, which is the reason why we use it as a target for transpiling. Concerning the new releases such as ES6, ES7, and all the way to ES2020, as of mid-2020, they are actually quite well supported already in all modern browsers. We usually call all the current versions together, ES6+.
If you want to stay up to date about what features are currently supported in which browser, you can check out the ES6 compatibility table. There are also future releases of the language like ES2021, ES2022, and so on. These future releases are usually called ESNext.
All this is actually relevant because most browsers actually start implementing new features even before they enter the official ECMAScript specification. That's possible because as new features are proposed, They have to go through four stages. At stage 1, they are first admitted all the way to stage 4, at which point they enter the language officially. When the feature is at stage 3, the browser can be pretty sure it will eventually pass to stage 4, and so, they are going to start implementing that feature while still in stage 3.
To finish, I'll try to keep you guys updated as these new features start coming out either through new lectures or articles.
Credit: @jonasschmedtman