arguments - reading optional attributes from optional setting in javascript -


What is the most effective way to read alternative attributes in the optional setting argument? I am using something like this:

  f = func (var1, optionalsettings) {var2 = (optionalsettings === undefined? 0: (Optional rupees ['var2'] == zero? 0: optionalsettings ['var2'])); };  

But I'm guessing it can be done more efficiently, either in javascript or in jquery

You can:

  var var2 = (options and Settings & amp; Options Options ['var2']) || 0;  

First you check that optionalsettings is present. If this happens, you try to return optionalsettings ['var2'] Please. If that fails, you come back to the default value.


Comments