| The dev blog for cloudno.de, a new Node.js hosting platform.

Node.js Version 6.10.2 Now Available

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 teest

Default function parameters

1
2
3
4
5
function multiply(a, b = 1) {
  return a * b
}

multiply(5) // 5

Learn more on the default function parameters.

Rest parameters

1
2
3
4
5
6
7
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

1
2
3
4
5
6
7
8
9
// 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

1
2
3
4
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

1
2
3
4
5
6
7
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.

1
2
3
4
5
6
7
8
9
10
11
12
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.

1
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

Comments