C#-like named argument in javascript?
Is it possible to use named argument in javascript?
E.g.
开发者_如何学Pythonvoid method (int a, int b);
method(a:1, b:2);
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 });
I believe the answer is 'no', but you can come to an approximation by using a single object with names properties/members as the argument to your functions. See here for more details.
精彩评论