

ECMAScript is generally used for client-side scripting, and it is also used for writing server applications and services by using Node.js.ĮS6 allows you to write the code in such a way that makes your code more modern and readable. This specification governs some languages such as JavaScript, ActionScript, and Jscript. var arr = ĮS5 for (var i = 0 i < arr.ES6 tutorial provides you the basic and advanced concepts.ĮS6 or ECMAScript 6 is a scripting language specification which is standardized by ECMAScript International. (param1, param2, paramN) => expressionĮS6 const multiplyES6 = (x, y) => ES5 var a = obj.a ĮS6 introduced a simple syntax for iteration through arrays and other iterable objects. They make the code more clear and simplify function scoping. Arrow functions are anonymous and change the way they bind to functions. They just use a new token, = >, which looks like a fat arrow. They save developers time and optimize the scope of functions.Īrrow functions, also commonly known as “fat arrow” functions, are a more clear and concise for writing function expressions. Understand var, let and const keywords in JavaScriptĪrrow functions were also implemented with ES6 as a new syntax for JavaScript functions.

ES6 const CONST_IDENTIFIER = 0 Also read: It does not mean the value it holds is immutable, just that the variable identifier cannot be reassigned. The const declaration creates a read-only reference to a value. A constant can not share its name with a function or variable in the same scope. The value of a constant can not change through reassignment, and cannot be redeclared. In ES6, “const” has block scoping like the “let” keyword. We will use the “const” keyword to generate and initialize a read-only variable that has a constant value and something that we can never change. Also read:ĮS5 var x = 0 ES6 let x = 0 Constant declarationĮS6 has introduced the const keyword, which cannot be redeclared or reassigned, but isn’t immutable. This is a difference from the var keyword, which defines a variable globally or locally for a whole function, regardless of the block scope. But now we can simply declare real block-scoped variables with the “let” keyword.

However, when it comes to scope, it has some limitations because it does not offer a block scope. Originally we used the keyword “var” to declare our variables. In the following table, we provide a brief overview of the concepts of scope and the differences between let, var, and const. Here is a summary of a number of the foremost common options and syntactic variations, where applicable, with comparisons to ES5. Several changes to JavaScript were introduced by ECMAScript 2015, also well-known as ES6.
