Created
September 12, 2014 17:56
-
-
Save dan-diaz/2cc9564cdf22563a6310 to your computer and use it in GitHub Desktop.
Default Settings Pattern
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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