Here's another alternative that is a little more efficient in defaulting the values. In the current code (with the || short-circuiting on the right-side of the assignment), assignments are always made, even if a value is already set. Using the syntax below, assignments are only made when the default value is needed.
var myFunc = function(config) {
config || (config = {});
config.property || (config.property = 123);
};
Please note that this is a micro-optimization and will never make a measurable performance difference, but I think it's a neat approach and the question itself is kind of micro-optimizey to start with :)
Edit: this is probably assumed, but perhaps worth saying anyway. Just make sure that your "is checked?" expression on the left-hand side of the
|| makes sense for the type of values being set. E.g., if
0 is a valid value, then you would want a more robust expression than what's currently there (which will assign the default on any falsey value). An alternative would be to check if the property is defined.
configbe anything? Semantically, it looks like it will either be undefined or an object (since you're assigning properties it must be in fact). Is there a reason why you don't use||?