
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 developers switched to the new version of the V8 engine: 4.6.85.25.
- npm updated to version 3.3.6.
- Added the ability to transfer file descriptors to function calls fs.readFile * (), fs.writeFile * () and fs.appendFile * ().
- Changed console.time output format
- In the buffer object, the 'Raw' and 'raws' encoding types are deleted.
- Calls for require.paths, util.p (), util.inherits (), require.registerExtension () have been discontinued
- Requirements for HTTP method names and headers tightened
- ALPN support added to tls module. Now the minimum DH key size for tls.connect () has been increased to 1024 bits.
- Support for the _linklist module has been discontinued.
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 callsfunction Foo() { if (!new.target) throw "Foo() must be called with new"; console.log("Foo instantiated with new"); } Foo();
new.target in constructors class A { constructor() { console.log(new.target.name); } } class B extends A { constructor() { super(); } } var a = new A();
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];
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.