JavaScript ES6
In this tutorial, you will learn about ES6 with help of Examples:
-
More significant changes than ES5
-
Much new syntax
-
Very, Very high back compat
-
ECMAScript 2015 is also known as ES6 and ECMAScript 6.
There are describes the most important features of ES6, are as follows:-
New Features in ES6
There are various new features in JavaScript:-
-
The let keyword
-
The const keyword
-
Arrow Functions
-
For/of
-
Map Objects
-
Set Objects
-
Classes
-
Promises
-
Symbol
-
Default Parameters
-
Function Rest Parameter
-
String.includes()
-
String.startsWith()
-
String.endsWith()
-
Array.from()
-
Array keys()
-
Array find()
-
Array findIndex()
-
New Math Methods
-
New Number Properties
-
New Number Methods
-
New Global Methods
-
Object entries
-
JavaScript Modules
JavaScript Let
-
Let is a block level variable.
-
Let you declare variables that are limited in scope to the block, statement, or expression.
-
Using var we can define a variable either globally, or locally to the entire function regardless of clock scope.
-
Let doesn’t allow duplicate variable creation.
Using let keyword in another example, a, b, and c, are variables is as follows:
Example -
Output
JavaScript Const
-
Constants are block level scope variables. The scope may be either global or local scope.
-
Constants are working like variables defined using let statements.
-
We can’t modify the value of constants.
-
Constant re-declarations are not allowed.
Using const keyword in another example, a, b, and c, are variables is as follows:
If you want a general rule: always declare variables with const.
If you think the value of the variable can change, use let.
Example -
Output -
JavaScript Arrow Function
In this tutorial, you will learn about Arrow Function in JavaScript with the help of Example:
Arrow functions were introduced in ES6.
Arrow functions help us to write shorter function syntax is as follows:
Example 1 -
Output -
JavaScript For Of
The for...of statement used to creates a loop iterating over iterable objects and over the built-in String, Array, array-like objects (e.g., arguments or NodeList), TypedArray, Map, Set and user-defined iterables etc..
The Syntax of for Of Loop is as follows:
for (element of iterable) {
// body of for… of
}
Example 1 -
Output -