Understanding EcmaScript : ES5 vs ES6 — I

Anis Alam
2 min readFeb 4, 2020

--

Hello Everyone ,
This is my first blog on medium. In this blog we will discuss about EcmaScript standard.
As you may aware that EcmaScript is a scripting-language-specification standardarized by ecma international in the ECMA-262 and ECMA-402 specifications. It was created to standarize Javascript by Brendan Eich of netscape.

ES5 and the ES6 (also known as EcmaScript 2009 & 2015) are the most popular and widely used standard for JS. In this blog we will discuss these two standards broadly. First Let’s discuss about ES5 :

ES5 : ES5 was first released in 2009 , 10 years after the previous version was released. ES5 had 5 main differences from ES3 :

  1. Strict Mode : In ES3 failure is silent i.e execution will happen assuming everything got successful. Programmers can’t check after every assignment to check if it was successful.
    In ES5 failure assignment throw. Using Strict mode you can’t use unused variables. It helps writing clean and error-free code.
    To enable this feature you just need to write “use strict” at the top of your js file.
use strict example code

2. function : The function in ES5 has 4 features :
a. the value of this will not be changed when calling .call() or .apply()
b. null and undefined will not be returned to global
c. a non-object will not be switched to an object
d. new method .bind() is introduced . the bind() method allows user to bind the value of this and apply the value to the function . Let’s understand with an example.

bind example (asked in Dassault interview)

3. Array : ES5 introduced a lot of new built-in array methods .
They are :
• Array.prototype.indexOf
• Array.prototype.lastIndexOf
• Array.prototype.every
• Array.prototype.some
• Array.prototype.forEach
• Array.prototype.map
• Array.prototype.filter
• Array.prototype.reduce
• Array.prototype.reduceRight

JSON : ES5 introduced two new methods to translate JSON data .

a. JSON.stringyfy() : This method takes a valid JOSN object as an argument and returns the string version of it.
b. JOSN.parse() : This method takes a string literal and converts it into a valid JSON.
example :

5. Properties and attribute :
ES3 code can only create properties that are writable ,enumerable and deletable.
ES5 introduced properties as writable , enumerable ,configurable and controllable.
Attribute values are programmatically settable and testable. Also accessor properties i.e getter and setter was added.

With this I am ending the first part of the Blog . Soon I will be publishing the last part explaining ES6.

Stay tuned :)

--

--

Anis Alam

Full Stack Engineer | Building Beautiful UI | Problem Solver