如何在Node.js中的服务器端使用Object.values()

问题描述:

Object.values()收到以下错误:


TypeError:Object .values不是函数。

TypeError: Object.values is not a function.

来自这个问题 - 我看到不支持 Object.values()在所有浏览器中。

From this question on * - I see that Object.values() is not supported in all browsers.

但我在服务器端使用Node.js中的函数 - 如何使用 Object.values()在Node.js中它看起来如此直观,如 Object.keys()

But I am using the function in Node.js on server side - How can I use Object.values() in Node.js it seems so intuitive like Object.keys()?

Object.values 中的新功能ES2017 的。这是非常前沿的。 Node.js从7.0版开始有完整的支持

Object.values is a new feature in ES2017. It is very bleeding edge. Node.js has full support for it from version 7.0.

6.8.1支持它,但它被认为是不稳定的,并被锁定在 - 和谐标志后面。

6.8.1 supports it, but it is considered unstable and is locked behind the --harmony flag.

您可以:


  • 升级到最新的Node.js LTS并使用 - harmony

  • 升级到最新的Node.js当前

  • 使用polyfill