0% found this document useful (0 votes)
19 views

JavaScript Object Properties

Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

JavaScript Object Properties

Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

JavaScript Object Properties

An Object is an Unordered Collection of Properties

Properties are the most important part of JavaScript objects.

Properties can be changed, added, deleted, and some are read only.

Accessing JavaScript Properties


The syntax for accessing the property of an object is:

// objectName.property

let age = person.age;

or

//objectName["property"]

let age = person["age"];

or

//objectName[expression]

let age = person[x];


Input:

Output:

JavaScript Object Properties


Access a Property with .
John is 50 years old.

Adding New Properties


You can add new properties to an existing object by simply giving it a value:
Output:

JavaScript Object Properties


Adding a new Property
John is English.

Deleting Properties
The delete keyword deletes a property from an object:
Output:

JavaScript Object Properties


Deleting a Property
John is undefined years old.

You might also like