Skip to content

Instantly share code, notes, and snippets.

@tjoskar
Forked from trey/javascript_object_settings.md
Last active December 18, 2015 13:18
Show Gist options
  • Save tjoskar/5788822 to your computer and use it in GitHub Desktop.
Save tjoskar/5788822 to your computer and use it in GitHub Desktop.

Create a JS Object with Overwritable Settings

var Fancy = {
	settings: {
		something: 'one',
		somethingElse: 'two'
	},
	init: function(options){
		var s = $.extend({}, this.settings, options);
	}
}

Call it like so:

Fancy.init({something: 'Luke', somethingElse: 'Wroblewski'});

That's one way to do it anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment