npr npr - 1 year ago 236
Javascript Question

How to use Object.values() on server side in Node.js

received following error:

TypeError: Object.values is not a function.

From this question on stackoverflow - I see that
is not supported in all browsers.

But I am using the function in Node.js on server side - How can I use
in Node.js it seems so intuitive like

Answer Source

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 supports it, but it is considered unstable and is locked behind the --harmony flag.

You can either:

  • Upgrade to the latest Node.js LTS and use --harmony
  • Upgrade to the latest Node.js Current
  • Use a polyfill
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download