The Object.defineProperty() method defines a new property directly on an object and returns the object. To change the flags, we can use Object.defineProperty. We cannot change it back, because define property doesn't work on non-configurable properties.
Syntax- Object.defineProperty(obj, prop, descriptor)
The Object.defineProperties() method defines new or modifies existing properties directly on an object, and returning the object.
Syntax- Object.defineProperties(obj, props)
Obj: The object on which to define or modify properties.
Props: An object whose own enumerable properties constitute descriptors for the properties to be defined or modified.
JavaScript Object.entries() method is used to return an array of a given object's own enumerable property [key, value] pairs. The ordering of the properties is the same as that given by looping over the property values of the object manually.
Syntax- Object.entries(obj)
Obj: It is an object whose enumerable property [key, value] pair are to be returned.
Return value: This method returns an array of the given object's own enumerable property [key, value] pairs.
The Object.freeze() method freezes an object that prevents new properties from being added to it. This method prevents the modification of existing property, attributes, and values.
Syntax- Object.freeze(obj)
Obj: The object to freeze..
Return value: This method returns the object that was passed to the function.
The Object.getOwnPropertyDescriptors() method returns all own property descriptors of a given object. The difference between getOwnPropertyDescriptors() and getOwnPropertyDescriptor() method is that getOwnPropertyDescriptors() method ignores symbolic properties.
Syntax- Object.getOwnPropertyDescriptors(obj)
obj: It is the object for which to get all own property descriptors.
Return value: This method returns an object which contains all own property descriptors of an object. This method might return an empty object if there are no properties.
The Object.getOwnPropertyDescriptor method allows to query the full information about a property and returns a property descriptor for an own property (that is, one directly present on an object and not in the object's prototype chain) of a given object.
Syntax- Object.getOwnPropertyDescriptor(obj, prop)
obj: It is the object in which to look for the property.
Prop: It is the name of the property whose description is to be retrieved.
Return value: It returns a property descriptor of the given property if it exists on the object.
The Object.getOwnPropertyNames() method returns an array of all properties (except those non-enumerable properties which use symbol) found directly upon a given object.
Syntax- Object.getOwnPropertyNames(obj)
obj: It is the object whose enumerable and non-enumerable own properties are to be returned.
Return value: This method returns an array of string that correspond to the properties found directly upon the object.
The Object.getOwnPropertySymbols() method returns an array of all symbol properties found directly upon a given object. This method returns an empty array unless you have set symbol properties on your object.
Syntax- Object.getOwnPropertySymbols(obj)
obj: It is an object whose symbol properties are to be returned.
Return value: This method returns an array of all symbol properties found directly upon the given object.
The Object.getPrototypeOf() method of JavaScript returns the prototype (i.e. the value of the internal [[Prototype]] property) of the specified object.
Syntax- Object.getPrototypeOf(obj)
obj: It is an object whose prototype is to be returned.
Return value: This method returns the prototype of the given object. If there are no inherited properties, this method will return null.
The Object.is() method of JavaScript is used to determine whether two values are the same value. There is a special built-in method that compares values.
Syntax- Object.is(value1, value2);
value1: The first value to compare.
value2: The second value to compare.
Return value: This method returns the prototype of the given object. If there are no inherited properties, this method will return null.
The Object.preventExtensions() only prevents the addition of new properties from ever being added to an object (i.e., prevents future extensions to the object). This change is a permanent that means once an object has been made non-extensible, it cannot make extensible again.
Syntax- Object.preventExtensions(obj)
obj: It is the object which should be made non-extensible.
Return value: It returns the object being made non-extensible.
The Object.seal() method of JavaScript seals an object which prevents new properties from being added to it and marks all existing properties as non-configurable. The object to be sealed is passed as an argument, and the method returns the object which has been sealed.
Syntax- Object.seal(obj)
obj: It is the object which should be sealed.
Return value: The Object.sealed() method returns the object which has been sealed.
The Object.setPrototypeOf() method sets the prototype (i.e., the internal [[Prototype]] property) of a specified object to another object or null. All JavaScript objects inherit properties and methods from a prototype. It is generally considered the proper way to set the prototype of an object.
Syntax- Object.setPrototypeOf(obj, prototype)
obj: It is the object which is to have its prototype set.
Prototype: It is the object's new prototype (an object or null).
Return value: This method returns the specified object.
The Object.values() returns an array which contains the given object's own enumerable property values, in the same order as that provided by a for...in loop.
Syntax- Object.values(obj)
obj: It is the object whose enumerable own property values are to be returned.
Return value: This method returns an array of a given object's own enumerable property value.