In addition, you can combine the specified function parameters with these by default:
function mergeWithDefaults (params, defaults={}) { var toRet = {}; for (atr in defaults) toRet[atr] = defaults[atr]; for (atr in params) toRet[atr] = params[atr]; return toRet; }
Then you can use this function for the default parameters in your function:
FormatGrid (params) { params = mergeWithDefaults (params, { 'backColor': '0xfff' });
If you call FormatGrid with parameters containing backColor, it will be used, otherwise it will be set by default by default (here "0xfff").
Hope this helps :) Pierre.
source share