Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configure Node to use Object.assign

I'm doing a simple test of Object.assign in both IO.js and Node.JS but its causing an error.

/Users/lp/.nvm/versions/io.js/v2.4.0/bin/iojs --debug-brk=59842 --nolazy mixin.js
Debugger listening on port 59842
/Users/lp/Documents/code/test/mixin.js:11
line = Object.assign(line, depth);
              ^
TypeError: Object.assign is not a function

Heres the code:

var line = {
  x: 0,
  y: 0
};

var depth = {
  z: 0
};

line = Object.assign(line, depth);

I've tried Node v0.12.7 with --harmony and IO.js v2.4.0. From what I read ES6 should be supported. Is assign not supported or am I missing something?

like image 725
longplay Avatar asked Mar 16 '23 07:03

longplay


1 Answers

http://kangax.github.io/compat-table/es6 is the best place to look right now and it says Object.assign is unsupported on iojs and node. It's easy enough to load a polyfill though.

The ES6 spec was only finalized last month, it isn't even close to fully implemented across platforms yet. You should plan to rely on polyfills and transpilers like Babel and Traceur if you'd like to use larger portions of ES6 on current platforms.

like image 127
loganfsmyth Avatar answered Mar 24 '23 02:03

loganfsmyth