Skip to content

Instantly share code, notes, and snippets.

@trey
Created May 30, 2012 05:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save trey/2833884 to your computer and use it in GitHub Desktop.
Save trey/2833884 to your computer and use it in GitHub Desktop.
Create a JavaScript Object with Overwrite-able Settings

Create a JavaScript Object with Overwrite-able 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.

@trey
Copy link
Author

trey commented May 30, 2012

@qichunren
Copy link

Is this require jquery or other js framework?

@trey
Copy link
Author

trey commented Dec 5, 2012

@qichunren, yes, I'm using jQuery here.

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