elibraryportal Logo

JS Object

Every thing is An object is real word entity that having state and behavior (properties and method).

Example:- car, Pen,chair, computer

How to creat objects in js

There are three way to create objects that is.

  1. Object literal
  2. Creating instance of Object directly (using new keyword)
  3. By using an object constructor (new keyword)

1) Object Literal in JS

Syntax:

Example:

Test it Now

2) Using new keyword in JS

Syntax:

Use this syntax create object

Example:

Test it Now

3) By using an Constructor Object

Object constructor create function with arguments where argument value can be assigned in the current object by using this keyword.

Example:

Test it Now
Next Topic