DEV Community

A K I L A N
A K I L A N

Posted on

Object in js

*Object *

  • object are varaiable which can store both values and functions

  • value are stores as key:valuesthis pairs is called properties.

  • function are stores a key:function() this pair is called a methods

  • key can be randomly name but values should proper

  • in values we can assign variables ex:caretype:type;

  • while in object we can use keyvaules as key or functionkeys.

  • we can use space in key but it should be only in string and in while print also should in string form ex:console.log(car["type"])

  • we can delete a particular properties use object.value ex:delete car.price

  • we can add properties after creating object ex:car['discount'] = 250000;

  • we can change the values of a properties by reassign the value ex:car.price = 5000000;

  • we can use function in the object and this.

Top comments (0)