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
  • 483
  • 4
  • 14

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
  • 313,535
  • 40
  • 245
  • 254