JavaScript Objects

Object creation, properties, methods and object manipulation in JavaScript.

Object Creation

var student = {                 # object name
    firstName:"Jane",           # list of properties and values
    lastName:"Doe",
    age:18,
    height:170,
    fullName : function() {     # object function
       return this.firstName + " " + this.lastName;
    }
};

Accessing Objects

student.age = 19;           # setting value
student[age]++;             # incrementing
name = student.fullName();  # call object function