Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C#-like named argument in javascript?

Tags:

javascript

c#

Is it possible to use named argument in javascript?

E.g.

void method (int a, int b);

method(a:1, b:2);

like image 676
Nam G VU Avatar asked Jan 27 '26 22:01

Nam G VU


1 Answers

In javascript you could do this:

function method(foo) {
    // use foo.a and foo.b here    
}

and then call it like this:

method({ a: 1, b: 2 });
like image 121
Darin Dimitrov Avatar answered Jan 29 '26 11:01

Darin Dimitrov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!