Member-only story

Object in Javascript with example

Bipsmedium
2 min readSep 13, 2022

--

  • Object in javascript is a kind of container for storing values or you can say it is a kind of variable with multiple values. As we all know that a javascript variable contains a single value which means we can only assign a single value to a javascript variable.
  • It holds the values using the name: value pair.
  • javascript object is declared with the keyword const.
  • parenthesis is used to declare javascript objects.

const object = {name:value,name1:value1,name2:value2};

Below is an example of a javascript object

const boy = {first_name: "Robin",last_name: "Sinha",age:30};

Also, you can write the above object as shown below

const boy = {

first_name: "Robin",

last_name: "Sinha",

age:30};

}

whereas boy is the name of the object
first_name is the property name
Robin is the property value

From the above example, you can see some values inside the object. Those values are known as object properties. These values can be used in the methods if we declare the methods along with the object properties. Also, note that we have to use the first bracket at the time of calling methods using the javascript objects.

--

--

Bipsmedium
Bipsmedium

Written by Bipsmedium

Hi, This is Biplab and I am a PHP laravel developer and other open source technologies. I am here to share my experience with the community.

No responses yet