ES6 New feature to begin with-Javascript

What is ES6?. It is short form of ECMA (European Computers Manufacturers Association) Script 6. ES6 is the 6th edition which was released in 2015. Please check the browser compatibility before using any of ES6 features.

Let us concentrate on the aim of this post, which is to see what’s new in javascript and how will it help us to make the development faster.


Support for constants (also known as Immutable Variable) i.e,variables which can not be
reassigned a new content. This only makes the variable itself immutable not it’s assigned content,therefore the object or an array assigned to a const variable can still be altered.

2.Arrow Functions

An arrow function expression has shorter syntax than a function expression and does not bind its own ‘this, arguments, super or’. These function expressions are best suited for non-method functions and hence they cannot be used as constructors.

3.Changes in parameters

Default parameter values
Simple and intuitive default values for function parameters in addition to earlier parametrs.

Rest parameter
The parameter with three dots in the beginning will handle all the parameters from that point. This could be especially used when we aren’t sure about the number of parameters which will be sent.

4.String Interpolation

Intuitive expression interpolation for a single line and multi-line strings.

make sure you don’t use quotes instead of ‘grave’ which is present with tilde in your keyboard and make the mistake which i did at first.

5.Binary and Octal literal

Finally, direct support for safe binary and octal literals.

6.Enhanced object properties

I found it little tricky to understand some of the changes, May be,I would recommend going through the concept by your own once again.

a. Property shorthand
obj = {x,y}; is equivalent to obj = {x:x,y:y};

b. Computed property names
Support for computed names in object property definition.

c. Method properties
Support for method notation in object property definitions for both regular functions
and generator functions in addition to computed property names. As a result we do not
have to specify the function expression separately.


Support for export/importing values from/to modules without global namespace pollution. It is better to go with default javascript rather than using AMDs like Require.js just for modularity.

8.for…of Operator

The for…of statement creates a loop iterating over iterable objects(including Array, Map, Set, String, TypedArray, arguments), invoking a custom iteration hook with statements to be executed for the value of each distinct property.

for(variable of iterable){

variable: – on each iteration, a value of a different property is assigned to variable.
iterable: – Object whose enumerable properties are iterated.

9.Generator function

The function* declaration defines a generator function, which returns a generator object.
We can also define generator functions using the ‘Generator function’ constructor and a function* expression.

Syntax: –
function* fname([param[,param….]]){
Generators are functions which can be exited and later re-entered. Their context will be saved across all re-entrances. Calling a generator function does not execute its body immediately; an iterator object is returned instead.

When the iterator’s next() method is called the generator function’s body is executed until the first yield expression, furthermore specifying the value to be returned from the iterator Or with yield*, delegates to another generator function.

The next() method returns an object with a ‘value’ property containing the yielded value and a ‘done’ property which indicates whether the generator has yielded its last value as a boolean.

Calling the next() method with an argument will resume the generator function execution replacing the yield statement where execution was paused with the argument from next().

Mozilla Developers Network is the best place to learn them.

Tagged as: ,