You can now choose the latest Node.js v6 version for your apps. This is the Long Term Support version purported to receive LTS maintenance until 2019-04-01, so you should make the change. You will also get a lot of improvements and new features:
- Module loading got 4-times faster
- Updated V8 engine
- 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 new Error('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 intercept-able 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.
How To Use It
To use Node.js v6 for a new application, select it from the the Virtual Machine Type.
Fig 1: Node.js v6 Virtual Machine Type
To switch your existing application to the LTS version make to following environment entry and restart your server.
Fig 1: Change your application to Node.js v6 Virtual Machine Type