Wait, What? About six months ago, Node Foundation announced version 5, well now its time to upgrade again. This new release of node aims to improve performance, reliability, usability and security.

0.12 , 0.14 , 5.* (where * represents any sub-version). If you are using any of these versions of node, you might want to consider upgrading your node install. Since 4.0 is LTS (long-term support), you don't have to upgrade yet as 4.* will have support until April of 2017.

The first thing you should know about any perfomance improvements is that, node now runs on the latest v8 engine.

Next is module loading speed. We have not run any tests, but node foundation has and claims that module loading is now four times faster.

According to node green, Node 6.0 supports 93% of ES6 (Ecmascript 6) features.

There is a new Buffer API that reduce the risk of bugs and vulnerabilities leaking into applications.

Deprecation of the current Buffer and SlowBuffer APIs.

and APIs. A new lastIndexOf method has been added to Buffer prototypal chain.

and many more.

With this new release, there are some features of es6 that we can use in Node. Speaking of improving usability, these features sure do go a long way to see to that.

This has been a long-awaited feature in node.js. Before this release, developers would do this to make sure that an argument has a default value.

function functionWithDefaultValue ( val ) { val = val || { } ; }

Now, we can just do this.

Upgrade Your JS Go from vanilla JavaScript 👉 React

Watch for FREE

function functionWithDefaultValue ( val = { } ) { }

This new operator lets us extract each array item as function parameter. Before the spread operator, we would do something like this.

function myFunc ( x , y , z ) { } var args = [ 0 , 1 , 2 ] ; myFunc . apply ( null , args ) ;

With the spread operator, we can now do something like this.

function myFunc ( x , y , z ) { } var args = [ 0 , 1 , 2 ] ; myFunc ( ... args ) ;

If we wanted to have variadic function in javascript, we use to make use of arguments , now we can use the spread operator to take in many parameters.

Before.

function variadic ( ) { console . log ( arguments ) ; } variadic ( 1 , 22 , 12 , 13 ) ; variadic ( 'adfsd' , { } , [ 1 , 12 ] ) ;

Now

function variadic ( ... args ) { console . log ( args ) ; } variadic ( 1 , 22 , 12 , 13 ) ; variadic ( 'adfsd' , { } , [ 1 , 12 ] ) ;

Well, what's the difference? arguments take all the parameters passed to the function. With this new operator, we can pass different variables before passing the spread operator.

function argumentsDemo ( ) { console . log ( arguments ) ; } argumentsDemo ( 2 , 2 , 24 , 2 , 4 , 4 , 2 ) ; function spreadDemo ( a , b , ... spread ) { console . log ( a , b ) ; console . log ( spread ) ; } spreadDemo ( 1 , 3 , '24' , 'lorem' ) ;

The destructuring assignment syntax is a JavaScript expression that makes it possible to extract data from arrays or objects into distinct variables.

var x = [ 1 , 2 , 3 , 4 , 5 ] var [ y , z ] = x console . log ( y ) console . log ( z )

It can also be used to swap variables

var a = 1 ; var b = 3 ; [ a , b ] = [ b , a ] ; console . log ( a ) ; console . log ( b ) ;

Read more on destructuring.

The Proxy object is used to define custom behavior for fundamental operations (e.g. property lookup, assignment, enumeration, function invocation, etc).

In this simple example, the number 37 gets returned as the default value when the property name is not in the object. It is using the get handler.

var handler = { get : function ( target , name ) { return name in target ? target [ name ] : 37 ; } } ; var p = new Proxy ( { } , handler ) ; p . a = 1 ; p . b = undefined ; console . log ( p . a , p . b ) ; console . log ( 'c' in p , p . c ) ;

More on proxies;

For those of you who write code in Java, PHP, or something similar, you might have head or reflection. Relect is Javascripts / nodes reflection. According to MDN

Reflect is a built-in object that provides methods for interceptable JavaScript operations.

Symbols are unique and immutable data type that may be used as an identifier for object properties. No two symbols can have the same value. For example.

Symbol ( 'scotch' ) !== Symbol ( 'scotch' ) ;

Read this article to learn more about es6 symbols.

At the moment, they are still trying to fix some kinks in the release — but by October of this year (2016), node 6.0 will be an LTS. Right now, if you want to play with the latest features, go right ahead. But that doesn't mean you can't start upgrading your codebase.

Like this article? Follow @KayandraJT on Twitter