top of page

JavaScript Class Notes: Objects

Updated: Oct 16, 2022

Mobiprep has created last-minute notes for all topics of Javascript to help you with the revision of concepts for your university examinations. So let’s get started with the lecture notes on javascript.

JavaScript Class Notes: Objects

Our team has curated a list of the most important questions asked in universities such as DU, DTU, VIT, SRM, IP, Pune University, Manipal University, and many more. The questions are created from the previous year's question papers of colleges and universities.

JavaScript Notes: Objects

Question 1. Explain JavaScript Objects.

A javaScript object is an entity having state and behaviour (properties and method). For example: car, pen, bike, chair, glass, keyboard, monitor etc.

JavaScript is an object-based language. Everything is an object in JavaScript.


Question 2. What are the three different ways to create an object in JavaScript?

There are 3 ways to create objects.

By object literal

By creating instance of Object directly (using new keyword)

By using an object constructor (using new keyword)

1) JavaScript Object by object literal:

The syntax of creating object using object literal is given below:


As you can see, property and value is separated by : (colon).

Let’s see the simple example of creating object in JavaScript.

emp={id:102,name:"Shyam Kumar",salary:40000}
document.write(" "" "+emp.salary);


102 Shyam Kumar 40000

2) By creating instance of Object:

The syntax of creating object directly is given below:

var objectname=new Object();

Here, new keyword is used to create object.

Let’s see the example of creating object directly.

var emp=new Object();;"Ravi Malik";
document.write(" "" "+emp.salary);


101 Ravi 50000

3) By using an Object constructor:

Here, you need to create function with arguments. Each argument value can be assigned in the current object by using this keyword.

The this keyword refers to the current object.

The example of creating object by object constructor is given below.

function emp(id,name,salary){;;
e=new emp(103,"Vimal Jaiswal",30000);

document.write(" "" "+e.salary);


103 Vimal Jaiswal 30000


Question 3. Define Object properties in JavaScript.

  • Object.assign() This method is used to copy enumerable and own properties from a source object to a target object.

  • Object.create() This method is used to create a new object with the specified prototype object and properties.

  • Object.defineProperty() This method is used to describe some behavioral attributes of the property.

  • Object.defineProperties() This method is used to create or configure multiple object properties.

  • Object.entries() This method returns an array with arrays of the key, value pairs.

  • Object.freeze() This method prevents existing properties from being removed.

  • Object.getOwnPropertyDescriptor() This method returns a property descriptor for the specified property of the specified object.

  • Object.getOwnPropertyDescriptors() This method returns all own property descriptors of a given object.

  • Object.getOwnPropertyNames() This method returns an array of all properties (enumerable or not) found.

  • Object.getOwnPropertySymbols() This method returns an array of all own symbol key properties.

  • Object.getPrototypeOf() This method returns the prototype of the specified object.

  • This method determines whether two values are the same value.

  • Object.isExtensible() This method determines if an object is extensible

  • Object.isFrozen() This method determines if an object was frozen.

  • Object.isSealed() This method determines if an object is sealed.

  • Object.keys() This method returns an array of a given object's own property names.

  • Object.preventExtensions() This method is used to prevent any extensions of an object.

  • Object.seal() This method prevents new properties from being added and marks all existing properties as non-configurable.

  • Object.setPrototypeOf() This method sets the prototype of a specified object to another object.

  • Object.values() This method returns an array of values.


Question 4. Explain the use of 'this' keyword in JavaScript.

The this keyword is one of the most widely used and yet confusing keyword in JavaScript. Here, you will learn everything about this keyword.

this points to a particular object. Now, which is that object is depends on how a function which includes 'this' keyword is being called.


Question 5. Define Screen Objects in JavaScript.

The screen object contains information about the visitor's screen.

Note: There is no public standard that applies to the screen object, but all major browsers support it.

Top 40 Javascript Interview Questions and Answers
Download PDF • 1.15MB


Mobiprep is a one stop solution for all exam preparation needs. Get all exam prep resources at a single platform.
Free Practice Tests
Top Placement Interview Questions
Top Placement MCQ's Questions

72 views0 comments

Recent Posts

See All
bottom of page