本文介绍了配置节点以使用Object.assign的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我在IO.js和Node.JS中做了一个简单的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

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

var depth = {
  z: 0
};

line = Object.assign(line, depth);

我用--harmony和IO.js v2.4.0尝试过Node v0.12.7。从我阅读ES6应该得到支持。分配不支持或我缺少某些东西?

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?

推荐答案

是现在最好的地方,它说Object.assign不支持iojs和节点。很容易加载一个polyfill。

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.

ES6规格仅在上个月完成,甚至没有完全实现跨平台。如果您想在当前平台上使用较大部分的ES6,您应该计划依靠Polyfill和透明胶片(如Babel和Traceur)。

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.

这篇关于配置节点以使用Object.assign的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 12:15