npr npr - 4 months ago 48
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


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