Skip to content

Instantly share code, notes, and snippets.

@dan-diaz
Created September 12, 2014 17:56
Show Gist options
  • Select an option

  • Save dan-diaz/2cc9564cdf22563a6310 to your computer and use it in GitHub Desktop.

Select an option

Save dan-diaz/2cc9564cdf22563a6310 to your computer and use it in GitHub Desktop.
Default Settings Pattern
var defaultSettings = {
x:0.5,
y:true,
}
var settings = defaultSettings;
function exampleFunction(userSettings) {
//extend settings object
for (var key in userSettings) {
if (userSettings.hasOwnProperty(key) && userSettings[key] !== undefined) {
settings[key] = userSettings[key];
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment