0

I have an object like below

const myObject = {
  param1: 'val-1',
  param2: myFunction,
  param3: {test: 'test'},
};

Now is there any dynamic way so I can pass this object properties as individual parameters like below?

callBack('val-1', myFunction, {test: 'test'});

Note: Number of Object properties are dynamic.

Paveloosha
  • 563
  • 2
  • 6
  • 15

1 Answers1

3

If, as it is in the question, the object's properties happen to be in the order you want to pass into the callback, you can use Object.values and spread them:

callBack(...Object.values(myObject));
CertainPerformance
  • 356,069
  • 52
  • 309
  • 320