Difference between ES5 and ES2015
So, let us have a look at some differences between ES5 and ES6 or ES2015.
|It is the fifth version or edition of ECMAScript.||It is the sixth version or edition of ECMAScript.|
|It was released in 2009.||It was released in 2015.|
|It supports primitive data types: string, number, boolean, null & undefined.||It has a new primitive data type named Symbol, which supports unique values.|
|Due to the absence of some features, the performance of ES5 is lower than ES6.||Due to the presence of new features, ES6 or ES2015 has higher performance than ES5.|
|The Manipulation of objects in ES5 or ECMAScript 2009 is more time-consuming.||The Manipulation of objects in ES6 or ECMAScript 2015 is less time-consuming than ES5.|
|In ES5 or ES 2009, both function & return keywords are used for defining the function.||In ES6 or ES 2015, a new feature of the arrow function was introduced, in which the function keyword is not used for defining a function.|
|It offers a wider range of communities supporting ES5 or ES 2009 compared to ES6.||It offers a lower range of communities supporting ES6 or ES 2015 compared to ES5.|
|A traditional for loop like other programming languages are used for iterating the elements of iterable objects.||In ES6, a for…of the loop is introduced for iterating the elements of iterable objects.|
Google Chrome 23, IE (Internet Explorer) 10, currently known as Edge & Safari 6 were the first browsers that fully support ES5 or ECMAScript 5. Later, Mozilla Firefox 21 and Opera 15 also started supporting ES5.
Google Chrome 58, Edge 14, Firefox 54, Safari 10, & Opera 55 are the browsers that fully support ECMAScript 2015 or ES6. Among these browsers, Edge 14 & Safari were the first browsers that fully support ES2015. ES2015 is not supported by Internet Explorer (IE).
What are the features of ES5 & ES2015?
Features of ES6 or ES2015
- Arrow functions
- Defining variables using let & const keywords along with var keyword.
- Use of Destructing, Rest & Spread Operators.
- Objects, Classes & Inheritance.
- Use of string methods like String.includes(), String.endswith(), String.endswith().
- New primitive data type, Symbol for defining unique values.
- For/of loop
- Template Literals
Features of ES5 or ES2009
- Use of “use strict mode“.
- Use of array methods like Array.isArray(), Array.forEach(), Array.map(), Array.filter(), Array.reduce(), Array.some(), Array.every() etc.
- Use of Trailing Commas & Multiline strings.
- JSON methods like JSON.stringify(), JSON.parse().
- Object Methods such as Object.defineProperty(), Object.create(), Object.keys() etc.
- Property names using reserved words.
Many other features are also included in ES5 and ES6.
The ES6 or ES2015 can be converted into ES5 code by using transpilation. For this, we can use two compilers: Babel and Traceur for converting ES6 code to ES5 code.