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?
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?
Share Improve this question asked Jul 26, 2015 at 0:56 longplaylongplay 2063 silver badges7 bronze badges 3-
2
Do you have a specific reference for what you read? kangax.github.io/pat-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. – loganfsmyth Commented Jul 26, 2015 at 1:35 - @loganfsmyth Wow that's a really good reference. I didn't know the implementations varied that much. I'll go with the polyfill. Thanks! – longplay Commented Jul 26, 2015 at 1:45
- @loganfsmyth If you ans I will select. – longplay Commented Jul 26, 2015 at 2:10
1 Answer
Reset to default 7http://kangax.github.io/pat-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.