神刀安全网

What's new in Node v6?

New “Current” version line focuses on performance improvements, increased reliability and better security for its 3.5 million users – https://nodejs.org/en/blog/announcements/v6-release/

Node.js v6 just got released – let’s take a look at the improvements and new features landed in this release.

What's new in Node v6?

Performance Improvements

Security Improvements

New ES6 Features

Default function parameters

function multiply(a, b = 1) {     return a * b }  multiply(5) // 5   

Learn more on the default function parameters .

Rest parameters

function fun1(...theArgs) {     console.log(theArgs.length) }  fun1()  // 0   fun1(5) // 1   fun1(5, 6, 7) // 3   

Learn more on the rest parameters .

Spread operator

// before the spread operator function myFunction(x, y, z) { }   var args = [0, 1, 2]   myFunction.apply(null, args)  // with the spread operator function myFunction(x, y, z) { }   var args = [0, 1, 2]   myFunction(...args)   

Learn more on the spread operator .

Destructuring

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

Learn more on destructuring .

new.target

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"   

Learn more on the new.target .

Proxy

The Proxy object is used to define custom behavior for fundamental operations.

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) // 1, undefined   console.log('c' in p, p.c) // false, 37   

Learn more on proxies .

Reflect

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

Learn more on reflect .

Symbols

A symbol is a unique and immutable data type and may be used as an identifier for object properties.

Symbol("foo") === Symbol("foo"); // false   

Learn more on symbols .

Trying Node.js v6

If you are using nvm , you only have to:

nvm install 6   

If you for some reason cannot you nvm, you can download the binary from the official Node.js website .

When should I migrate to Node 6?

In October Node.js v6 will become the LTS version – after that, you should make the change.

转载本站任何文章请注明:转载至神刀安全网,谢谢神刀安全网 » What's new in Node v6?

分享到:更多 ()

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址