Pass to method object values as arguments

Viewed 136

I have next code:

someFunct(Object.values(Obj));

What I need is to pass object values in to 'someFunct' as separate argument, not as array.

2 Answers

You should use spread operator ...

someFunct(...Object.values(Obj));

Note: This method may cause some problems in code because Object.values() is not guaranteed to have same order. The better option is to pass and object and then destructure it.

You can use the spreading operator to spread the values:

someFunct(...Object.values(Obj));
Related