You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The zipToObject function exists in the library to combine a key array and a value array into an object, but there is no method to convert an object into two arrays (one array of keys and one array of values, where keys and values correspond to each other in the same array positions).
Below is a scenario that supports my need:
Suppose I want to dynamically create a function, and the parameters of this function are uncertain, depending on how many properties exist in a given context object (the order of the parameters does not matter). Below is a piece of pseudocode:
constcontext={// some key values}const[keys,values]=unzipFromObject(context)constdynFn=newFunction(...[ ...keys,'function body'])dynFn.apply(undefined,values)// invoke the dynamic fn created above``
stage 0: proposedA proposal for a change that is offered for community and team evaluation.
1 participant
Converted from issue
This discussion was converted from issue #275 on October 19, 2024 16:57.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
The
zipToObject
function exists in the library to combine a key array and a value array into an object, but there is no method to convert an object into two arrays (one array of keys and one array of values, where keys and values correspond to each other in the same array positions).Below is a scenario that supports my need:
Suppose I want to dynamically create a function, and the parameters of this function are uncertain, depending on how many properties exist in a given context object (the order of the parameters does not matter). Below is a piece of pseudocode:
Beta Was this translation helpful? Give feedback.
All reactions