Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save nealfennimore/11184910 to your computer and use it in GitHub Desktop.
Save nealfennimore/11184910 to your computer and use it in GitHub Desktop.
Literal notation and constructor notation
// Literal notation
var config = {
openOnLoad: false,
defaultName: "Jane"
};
// Constructor notation
var config = new Object();
config.openOnLoad = false;
config.defaultName = "Jane";
// ----------------------------
// Works even though declared before (not set to variable)
console.log( adder(1,2) );
// Not declared after function - results in error
console.log(subtractor(5,3));
console.log(apple);
var subtraction = functions(x,y){
return x-y;
}
function adder(x, y) {
return x+y;
}
var adder = new Function("x", "y", "return x+y");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment