Node: Could you make Object in nodejs have ...Object operator?

Created on 19 Jul 2018  路  3Comments  路  Source: nodejs/node

  • Version: latest
  • Platform: Any
  • Subsystem: Any

I have an ideal that why we don't make Object in nodejs can Extract.
This look like

const object = { a : "a", b : "b"};
console.log(...object);
//print: a b 

That mean we extract object to a list of property and value

Thank for reading.
Have Fun Coding.

question

All 3 comments

Sorry if it existed. Could you share me if it exists?

Spread operator for Objects is available only in Object literals:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax#Spread_in_object_literals

You can get the needed result in this way:

const object = { a: "a", b: "b" };
console.log(...Object.values(object));
// print: a b

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/values

Thanks for asking @kitokip! I think @vsemozhetbyt answered the question: This would be a language-level feature (ES6), not something that has to do with node. Closing as answered.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

stevenvachon picture stevenvachon  路  3Comments

addaleax picture addaleax  路  3Comments

jmichae3 picture jmichae3  路  3Comments

Brekmister picture Brekmister  路  3Comments

willnwhite picture willnwhite  路  3Comments