Chapter 3: Client-Side Scripting Language
Chapter 3: Client-Side Scripting Language
JavaScript Object
• Objects are a peace of data that has property and method.
• Object properties are usually variables that are used internally
in the object's methods, but can also be globally visible
variables that are used throughout the page. Objects are
variables too. But objects can contain many values
• This code assigns many values (Fiat, 500, white) to a variable
named car:
var car = {type:"Vitz", model:500, color:"white"};
• The values are written as name: value pairs (name and value
separated by a colon). JavaScript objects are containers for
named values.
• The syntax for adding a property to an object is −
objectName.objectProperty = propertyValue;
2
Object Methods