Objects in JS:
=> Objects contains Informations and mulitiple variables.
=> Objects used to store structured datas.
=> Values are stored as key:value pairs called properties.
=> Functions are stored as key:function() pairs called methods.
Example:
price of an tomato.
let price= $2;
let price= $3;
let price= $2; and so on....
if we print a variable (price), we can get any value from the name of variable (price).
=> To control the lines and to group the set of lines we can use object.
Example for object:
Output:
20,000
Accessing JavaScript Properties:
You can access object properties in these ways:
- Dot notation
- Bracket notation
- Expression
Output:
8
JavaScript Object Properties
- Properties are key:value Pairs
- A JavaScript object is a collection of properties
- Properties can be changed, added, and deleted.
JavaScript Object Methods
- What are Object Methods?
=>Methods are actions that can be performed on objects.
=>Methods are functions stored as property values.


Top comments (0)