Title says it all I have the following function :
var foo = function(arg1, arg2,arg3) {
// code
}
I want to do something like :
foo('bar', (x == true ? arg2, arg3 : arg2,arg3))
But I get hit with SyntaxError: Unexpected token , what is the right syntax to do something like this?
I would go with readability as JCOC611 said...
Yet, the "right" way is using .apply():
foo.apply(this, (x == true ? [arg1, arg2, arg3] : [arg1 ,arg2, arg3]))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With