JavaScript Object.getOwnPropertyNames() Method4 Sept 2024 | 1 min read 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:Parameter: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. Browser Support:
Example 1Output: ["a", "b", "c"] Example 2Output: ["0", "1", "2"] "0 -> a" "1 -> b" "2 -> c" Example 3Output: size,shape Next TopicJavaScript Objects |
JavaScript Object.seal() Method The of JavaScript seals an object which ents 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) Parameter: obj: It...
1 min read
JavaScript Object.is() Method The 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); Parameter value1: The first value to compare. value2: The second value to compare. Return value: This method returns a Boolean indicating whether or not...
1 min read
JavaScript Object.values() Method 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) Parameter: obj: It is the object whose enumerable own property values are to be returned. Return value: This method returns an array of...
1 min read
JavaScript Object.setPrototypeOf() Method The 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) Parameters: obj:...
2 min read
JavaScript Object.defineProperty() Method The 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) Parameter Obj: The Object on which to define the...
1 min read
JavaScript Object.entries() Method JavaScript 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) Parameter Obj: It is an object whose...
1 min read
JavaScript Object.freeze() Method The freezes an object that ents new properties from being added to it. This method ents the modification of existing property, attributes, and values. Syntax: Object.freeze(obj) Parameter Obj: The object to freeze. Return value: This method returns the object that was passed to the function. Browser Support: Chrome 45.0 Edge 12.0 Firefox 32.0 Opera No Example 1 const object1 =...
1 min read
JavaScript Object.getOwnPropertyDescriptors() Method The Object. returns all own property descriptors of a given object. The difference between getOwnPropertyDescriptors() and getOwnPropertyDescriptor() method is that ignores symbolic properties. Syntax: Object.getOwnPropertyDescriptors(obj) Parameter obj: It is the object for which to get all own property descriptors. Return: This method returns an object which contains all own...
1 min read
JavaScript Object.defineProperties() Method The defines new or modifies existing properties directly on an object, and returning the object. Syntax: Object.defineProperties(obj, props) Parameter 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. Return: This method reruns...
1 min read
JavaScript Object.getPrototypeOf() Method The of JavaScript returns the prototype (i.e. the value of the internal [[Prototype]] property) of the specified object. Syntax: Object.getPrototypeOf(obj) Parameter 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,...
1 min read
We request you to subscribe our newsletter for upcoming updates.
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India