norman784
norman784

Reputation: 2221

Harmony destructuring ReferenceError: Invalid left-hand side in assignment

This a weird behaviour, i've tested on Chrome and works just fine without any flag, but in node it doesn't work event with the latest version

$ node --harmony_destructuring app.js

[length, offset] = this.getint(data, offset, 2)
^    
ReferenceError: Invalid left-hand side in assignment

$ node -v

v5.11.0

Any clues on why it doesn't work or a version of node in witch works?

Thanks

Upvotes: 2

Views: 1325

Answers (1)

The correct syntax would be

const iterable = ['a', 'b'];
const [x, y] = iterable;

You can read more on destructuring here.

Upvotes: 3

Related Questions