Created
April 22, 2014 16:06
-
-
Save nealfennimore/11184910 to your computer and use it in GitHub Desktop.
Literal notation and constructor notation
This file contains 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
// 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