Skip to main content
0:00est. 3 min

Chapter 30- Objects and the Dot

Notes

In javascript, Objects and functions are very much related
- Object and the dot
- Object can have primitive connected to it "property"
- An object can have an object connected to it as a child "property"
- An object can also contain functions "method"
So an object can have properties and methods and these sit in the memory. Following example shows how to access these methods and properties.
Example 1
var person = new Object();
//person will get reference of the firstname in memory ie string property (primitive)
person["firstname"] = "Tony";

//accessing the property
var firstNameProperty = "firstname";
console.log(person[firstNameProperty]);

//accessing property with dot operator
console.log(person.firstname);

//creating object inside object
person.address = new Object();

//using dot operator to add properties
person.address.street = "111 Main st.";