📜 ⬆️ ⬇️

Stable release Node v5


Last week, the release of Nodejs v5. This branch includes a portion of new features and will be developed in parallel with the Node v4.x branch, which is a stable LTS branch with a long support period of 30 months. Node v5.x releases will be released every 8 months.

If you decide to upgrade to this version, then you should know that this will require rebuilding the installed third-party extensions, and there are some changes that violate backward compatibility. Keep this in mind.

Details under the cut.

So, what's new:

The full list of changes can be found in the official blog at the link nodejs.org/en/blog/release/v5.0.0
')

Support for new syntax instructions for ES6


Support new.target

The new operator is now used not only to create new objects, but also to be able to control the object being created and receive information about the object. The new.target operator will return a reference to the constructor function when creating the object. during a normal function call, new.target returns undefined.

Examples of using

new.target in function calls

function Foo() { if (!new.target) throw "Foo() must be called with new"; console.log("Foo instantiated with new"); } Foo(); // throws "Foo() must be called with new" new Foo(); // logs "Foo instantiated with new" 


new.target in constructors
 class A { constructor() { console.log(new.target.name); } } class B extends A { constructor() { super(); } } var a = new A(); // logs "A" var b = new B(); // logs "B" 

Spread operator support

Spread operator allows you to expand expressions in cases where the use of several arguments is provided, such as function calls or as array literals.

When calling functions:
 f(...iterableObj); 


In array literals:
 [...iterableObj, 4, 5, 6] 


With destructive assignment:
 [a, b, ...iterableObj] = [1, 2, 3, 4, 5]; 


Where can be used

 let arr1 = [0, 1, 2], arr2 = [3, 4, 5]; //    Array.prototype.push.apply(arr1, arr2); //      arr1.push(...arr2); 

The developers are already planning to release a new version of Node v6, which is scheduled for April 2016. This version should already receive LTS status.

Source: https://habr.com/ru/post/269971/


All Articles