DEV Community

Keerthana M
Keerthana M

Posted on

Objects in JS

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:

  1. Dot notation
  2. Bracket notation
  3. Expression

object inside the object

Output:
8

JavaScript Object Properties

  1. Properties are key:value Pairs
  2. A JavaScript object is a collection of properties
  3. Properties can be changed, added, and deleted.

JavaScript Object Methods

  1. What are Object Methods?

=>Methods are actions that can be performed on objects.

=>Methods are functions stored as property values.

Top comments (0)