30
rated 0 times
[
35]
[
5]
/ answers: 1 / hits: 7654
/ 10 Years ago, sun, february 23, 2014, 12:00:00
I have a function, in Javascript
function asd(foo, bar, baz) {
// ...
}
And each of those 3 arguments is required.
Suppose I have those arguments grouped as an object:
var x = {
foo: 10,
bar: 20,
baz: 30
};
Can I call function asd
just by giving object x
somehow unpacked? Can this be done generically? i.e., not knowing the signature of asd
.
I'm searching for something like kwargs unpacking in Python:
def asd(foo, bar, baz):
# ...
kwargs = {'foo': 10, 'bar': 20, 'baz': 30}
asd(**kwargs)
A no, not possible answer is acceptable. I just want to know whether this is possible in Javascript.
More From » python