Created
March 11, 2016 18:14
-
-
Save csdear/dd3caf9353b7f70b2b49 to your computer and use it in GitHub Desktop.
A SIMPLE JS OBJECT AND ACCESS VIA DOT NOTATION. • An object, person1, with two property slots and one method slot.
This file contains hidden or 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
//testable via console | |
var person1 = { | |
lastName : "Dear", | |
firstName : "Stuart", | |
getFullName : function () { | |
return this.firstName + " " + this.lastName; | |
} | |
}; | |
person1.firstName; | |
//Outputs : "Stuart" | |
person1.lastName; | |
//Outputs : "Dear" | |
person1.getFullName(); | |
//Outputs : "Stuart Dear" | |
//TEMPLATE / Object Scaffold | |
var <<objName>> = { | |
<<dataPropertyName>> : "<<value>>", | |
<<dataPropertyName>> : "<<value>>", | |
<<methodPropertyName>> : function () { | |
return this.<<//someVariable>>; | |
}}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment