React ES6

ES6

ES6 stands for ECMAScript6. ES6 was released in 2015 and is also known as the ECMAScript 2015. It is basically a standard, which the scripting languages have to follow.

As we know, Javascript is a scripting language. JS also follows ES6 standards. ES6 helps to standardize JS. After ES6, JS got many new features like let keyword, Arrow functions, Rest and Spread Operators, Classes, Array and object destructuring, default parameters and the list goes on. These newly introduced features are very much useful to minimize the no. of lines of code.

React ES6

React Js is a Javascript library, which is used for creating single page applications. The reason for React Js’s popularity is its features like code reusability, single page application.

React ES6 is the combination of React and ES6 standards. React Js was first inroduced in year 2013. Since then it got many features, one of which is the adoption of ES6 syntax. ES6 syntax makes the code more precise and concise. For example, Use of Arrow functions instead of regular functions.

In the above example both the function performs the same addition operation, but sum2 (Arrow function) is a more cleaner way to write the code.

Features of React ES6

React ES6 includes many new features, which are listed below :-

  • Classes and objects
  • Rest and spread operators
  • Array and object destructuring
  • let and const keyword
  • Array methods like .map(), .filter() and .reduce()

Difference between ES6 and ES5

ES5

  1. It was the 5th version of the ECMAScript.
  2. ES5 is more older, hence it has more community support.
  3. Code writing in ES5, was more time consuming.
  4. There was always risk of changing constant values by mistake, as there was no const keyword.
  5. ES5 also had the problem of variable conflicts, because a variable declared using the var keyword is global and change it’s value inside any other block results in change of the global variable.
  6. There was only simple for loop.

ES6

  1. It is the latest and 6th addition of the ECMAScript.
  2. It has community support, but less than the ES5.
  3. It makes the code more concise with features like destructuring and spread operators.
  4. Constant values can be declared using the keyword const.
  5. Variables can be declared using let keyword to avoid the scope related problems.
  6. ES6 has the for of loop, which can be used to iterate over the objects, more efficiently.

Leave a Reply

Your email address will not be published. Required fields are marked *