Skip to content
Related Articles
Open in App
Not now

Related Articles

JavaScript Object Complete Reference

Improve Article
Save Article
  • Difficulty Level : Medium
  • Last Updated : 14 Feb, 2023
Improve Article
Save Article

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

Syntax:

objectName.methodName()

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

HTML




<p id="gfg"></p>
<script>
    // Object creation
    var student = {
    name: "Martin",
    class : "12th",
    section : "A",
     
    studentDetails : function() {
        return this.name + " " + this.class
            + " " + this.section + " ";
    }
        };
         
        // Display object data
        document.getElementById("gfg").innerHTML
    = "STUDENT " + student.studentDetails();
</script>

Output:

STUDENT Martin 12th A

The complete list of JavaScript Object is listed below:

JavaScript Object Static Methods:

Static Methods

Description

assign()Copy the values and properties from one or more source objects to a 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()Definesobject a new or modifies existing properties directly on an object and it returns the object.
entries()Return an array consisting of enumerable property [key, value] pairs of the object.
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 the own property of a given object.
getOwnPropertyNames()Returns all properties that are present in a given object.
getOwnPropertySymbols()Returns an array of all symbol properties that are present in a given object.
getPrototypeOf()Check the prototype of an object that the user has created.
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()Return an array whose elements are strings corresponding to the 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()Return an array whose elements are the enumerable property values found on the object.

JavaScript Object Instance Properties:

Instance Properties

Description 

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

Instance Methods

Description

defineGetter__()Called when the specified property is looked up
hasOwnProperty()Check 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 is the object’s own property.

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!