What is ES6 and Learn JavaScript 6 Concepts

Javascript Concepts for interviews

  • Synonyms: ECMAScript 6, ECMAScript 2015, JavaScript 6.
  • JavaScript is a subset of ECMAScript.
  • Previously javascript. Netscape approach to ECMA and then after it is known as ECMAscript.
  • ECMA does language standardization.
  • However, ES6 tackles a lot of the limitations of the core language, making it easier for devs to code.

Now let’s understand ES6 concepts.

1.) Template strings

  • Template literals :- string literals with support of multi lines and interpolation
  • Tagged template literals :- function calls with template literals.

Template literals — Using backtick. Ex :- `…`. And Expression with $ sign and curly braces ${…}.

Tagged Template Literals

2.) Let, Const, Var

Difference between Let, Const, Var

  • Var

The scope is global when a var variable is declared outside a function. This means that any variable that is declared with var outside a function block is available for use in the whole window.

var is function scoped when it is declared within a function. This means that it is available and can be accessed only within that function.

Hoisting of var

Hoisting is a JavaScript mechanism where variables and function declarations are moved to the top of their scope before code execution. This means that if we do this:

it is interpreted as this:

  • Let

A block is a chunk of code bounded by {}. A block lives in curly braces. Anything within curly braces is a block.

Hoisting of let

Just like var, let declarations are hoisted to the top. Unlike var which is initialized as undefined, the let keyword is not initialized. So if you try to use a let variable before declaration, you'll get a Reference Error.

  • Const

const declarations are block scoped
const cannot be updated or re-declared

3.) For loop

4.) Default Parameters

5.) Arrow Functions


  • Shorter syntax => compared to function
  • this picked from lexical scope.
  • They are always anonymous.
  • () => “Hey”; // no argument
  • x => x * x; // one argument
  • (x, y) => x + y; //multiple argument

6.)Rest Operator (Parameters)

Rest operator “…” in last parameter of function means it will receive all the remaining parameters.

7.) Spread Operator

Allows expression to be expanded where multiple argument (for functions), multiple elements (for array) or multiple variables (for destructing) are expected.

Both operator looks same “…” but both are opposite to each other.

Spread element expands an array into its element where rest element collects multiple element and “condenses” into single element.

Spread operator is used for destructing arrays and objects.

8.) Destructing

Convenient way to extract data stored in array or objects.

Object Destructing


It is used for asynchronous computation. It represents value which may be available now, or in future or never. So it can be pending, fulfilled or rejected.

10.) Lexical Scope

11.) Closure

The closure has three scope chains:

  • it has access to its own scope — variables defined between its curly brackets
  • it has access to the outer function’s variables
  • it has access to the global variables.