Java script Objects overview

Java script – Objects overview

Java script is object oriented programming language. It has the following object oriented concepts such as,

  • Encapsulation
  • Polymorphism
  • Inheritance
  • Aggregation

16.1 Encapsulation

Encapsulate means capsule is covered with layer. Likewise encapsulation is putting data and method into a single container known as object. Many instances can be taken from the object.

16.2 Polymorphism

Polymorphism means many ways such as same method or function is used for multiple purpose.

16.3 Inheritance

The task of getting properties from their ancestors is called as inheriting.

16.4 Aggregation

The task of nesting more than one object is known as aggregation.

16.5 Object Properties

In object oriented programming paradigm each entity is referred to as objects. Objects have properties and methods. Property values decide the appearance of the object.

Syntax for accessing property of object

In the above two examples document is the object name. title and cookie are the properties of the object document.

16.6 Object methods

Methods are functions to perform operations on the properties of the object.



document is the object name and write is the method name to display content on the current document.

16.7 User defined objects

An object is an instance of user defined variable. The user defined object has two parts such as data and methods.

The new operator

new is the keyword (or) operator to create objects.

Object() constructor

Constructor is also one of the method to derive objects. It is followed by the keyword new.


java script objects overview img1

16.8 Accessing properties using this keyword


java script objects overview img1


java script objects overview img2

16.9 Assigning functions as object’s methods

Object has two parts such as properties and methods. The following example illustrate how the function work as method for object.

java script objects overview img3


function ‘per’ is created with one argument named as percentage. Object student is constructed using ‘new’ operator.


The above syntax is used to assign values for the arguments of the function per.

Using ‘this’ pointer that function is assigned as object’s one of the property.


16.10 With key word in java script

The keyword is for Accessing properties and methods of object without specifying object name and (.) operator.

Example program:

java script objects overview img1


Student rollno : 100

Name is : Lakshmi

Percentage is : 98