Skip to content

Instantly share code, notes, and snippets.

@csdear
Created March 11, 2016 18:14
Show Gist options
  • Save csdear/dd3caf9353b7f70b2b49 to your computer and use it in GitHub Desktop.
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.
//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