Skip to content

Instantly share code, notes, and snippets.

@psiborg
Created January 6, 2012 08:18
Show Gist options
  • Select an option

  • Save psiborg/1569650 to your computer and use it in GitHub Desktop.

Select an option

Save psiborg/1569650 to your computer and use it in GitHub Desktop.
JS Object Defaults 1
function setBG (options) {
var args = {
red: 255,
green: 255,
blue: 255
}
// overwrite defaults
for (var i in options) {
args[i] = options[i];
}
document.body.style.backgroundColor = "rgb(" + args.red + "," + args.green + "," + args.blue + ")";
}
setBG({red: 128, blue: 100});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment