Unpacking all the objects separately from an object received as parameter in a function

169 Views Asked by At

Can we unpack all the objects 'as separate objects' of a parent object which is received as the parameter in a function? I know that it may be done as funName(objA, ObjB){---} but can it be done by anyway without having to mention individual objects as (objA, ObjB) while receiving?

It may sound confusing, hence here is a case to ease understanding. I have a total of 12+ cached DOM elements, which are later used in 5-6 functions depending upon the need. What I really wish to have is that I could receive them in those later functions and could use them by their names. A nonsensical sketch of thoughts may or may not look like the following, perhaps it might help understand my challenge:

Function mainFunction() {
   parentObj = {objA: "$_el1", objB: "$_el2"..many more..};
   subFunc1(parentObj);
}

subFunc1(...) {
   objH.css("backgroundColor": "#f5f5f5");
}

Can any of you tell me if this is possible? If yes, How! Any help or guidance will be much appreciated. Thanks in advance.

1

There are 1 best solutions below

2
On

without having to mention individual objects

… and could use them by their names.

are mutually exclusive.