JavaScript objects are the most important data type and building blocks of modern JavaScript. The “Object” class represents JavaScript data types. Objects are very different from JavaScript’s primitive data types (Number, String, Boolean, null, undefined, and symbols). It is used to store different types of key collections and complex entities. It can be created using the Object() method or using object initialization/literal syntax.

Syntax:

objectName.methodName()

Example:  Using function definition as property value and accessing with additional details.

Javascript

// Object creation
let student = {
    name: "Smith",
    class: "10th",
    section: "A",
 
    studentDetails: function () {
        return this.name + " " + this.class
            + " " + this.section + " ";
    }
};
 
// Display object data
console.log("STUDENT " + student.studentDetails());

Output:

STUDENT Smith 10th A

The complete list of JavaScript Object is listed below:

JavaScript Object Properties: A JavaScript property is a member of an object that associates a key with a value.

  • Instance Properties: An instance property is a property that has a new copy for every new instance of the class.

Instance Properties

Description 

constructor Returns a reference to the object constructor function that has created the instance of an object.

Please Check all JavaScript articles HERE. For more such post you can refer HERE.


JavaScript Object Methods: JavaScript methods are actions that can be performed on objects. 

  • Static Methods: If the method is called using the Object class itself then it is called a static method of Object.

Static Methods

Description

assign() It is used to copy values ​​and properties from one or more source objects to the target object.
create() JavaScript does not have the traditional classes seen in other languages.
defineProperty() Defines a new property directly on an object and returns the object.
defineProperties() Defines a new object or modifies existing properties directly on an object and returns that object.
entries() Returns an array of the object’s enumerable [key, value] attribute pairs.
freeze() There is a method Object.freeze() which is used to freeze an object.
fromEntries() Transform a list of key-value pairs into an object.
getOwnPropertyDescriptor() Returns a property descriptor for a given object’s own property.
getOwnPropertyNames() Returns all properties that are present in a given object.
getOwnPropertySymbols() Returns an array of all symbol properties contained in a given object.
getPrototypeOf() Check the prototype of an object that the user has created.
hasOwn() Checks if a given property exists or not
Object.is() Determine whether two values are the same or not.
isExtensible() Checks whether an object is extensible or not.
isFrozen( ) Determine if an object is frozen or not.
isSealed( ) Determine if an object is sealed or not.
keys() Returns an array whose string elements correspond to enumerable properties.
preventExtensions() Additionally, it prevents the prototype of the item from being changed.
seal() There is a method Object.seal() which is used to seal an object.
setPrototypeOf() The internal [[Prototype]] property of a specified object to another object or null.
toLocaleString() It returns a string representing the object.
values() Returns an array whose elements are enumerable property values ​​found on the object.
  • Instance Methods: If the method is called on an instance of a date object, then it is called an instance method.

Instance Methods

Description

defineGetter() Called when the specified property is looked up.
hasOwnProperty() Checks whether the object has the specified property as its own property.
isPrototypeOf() Checks if an object exists in another object’s prototype chain.
IsEnumerable() Returns a Boolean indicating whether the specified property is enumerable and whether it is a private property of the object.
Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, codeConfig.in Courses are your key to success. We provide top-quality content at no cost, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!

Explore More

How to Center a Popup Window on Screen

JavaScript window.open() method is used to open a popup window. This popup window will be placed in the center of the screen. This example creates the pop-up window without placing it into

How to hide URL in the popup window opened using window.open

If you are using below code to open a popup window in your web page, then address must be appearing in you pop up window and f you want to

window.showModalDialog is deprecated in Edge and Chrome

If you have a website being compatible with Edge/Chrome and in past it was only compatible with IE 11 and if you are using window.showModalDailog in your JavaScript code, then