Javascript ES6 Features
Top 10 ES6 Features
What is ES6?
Es6 or ECMAScript 2015 is the sixth major release of ECMAScript language which comes with a lot of new features and syntax for writing web applications in Javascript.
Here we will discuss the core features of Top 10 ES6 or ECMAScript 6. I have divided my ES6 feature into 2 parts
# Block Bindings
# Function
# Block Bindings:-
* Var Declarations and Hoisting.
* Block-Level Declarations.
* Block Binding in Loops.
* Global Block Bindings.
* Emerging Best Practices for Block Bindings.
# Function
* Default Parameter Values.
* Working with Unnamed Parameters.
* The Spread Operator.
* Block-Level Functions.
* Arrow Functions.
* Var Declarations and Hoisting.
If you want to know about variable declarations, you need to know about scope first.
What’s the scope?
Scope is the means of making variable declarations.
Scope There are usually 2 types
i) Global scope
ii) Functional scope
~ Global scope can be accessed from anywhere
~ Functional scope will only be used inside the function, access will not be available from other places
Hoisting:-
Other programming languages would show it as an error but javascript is who it shows undefined because javascript here saves the value of y as empty.
* Block-Level Declarations.
If any variable is declared in Curly Braces, it is called Block-Level Declarations.
Example
* Block Binding in Loops:-
Most of the JavaScript loops work inside one of the Curly Braces or Blocks. We usually see i variable will be accessible only in the for loop and will not be accessible from outside. So to fix this in JavaScript, ES6 has introduced the let & const
like → for loop
* Global Block Bindings:-
The scope that is declared global or returns with a window object is called Global Block Bindings.
Global Block Bindings are usually declared out of function