Idiomatic way to set default value in JavaScript
If myObj is a global it needs to reference the window object, otherwise it will throw an error if myObj
is undefined.
myParam = myParam || (window.myObj ? window.myObj.mParam : 10);
or
myParam = myParam || (window.myObj && window.myObj.mParam) || 10;
This works as well:
myParam = myParam || ((typeof myObj !== "undefined") ? myObj.mParam : 10);