Set has() JavaScript

The JavaScript Set has() method indicates whether the Set object contains the specified value element. Syntax: setObj.has(value) Parameters: value: It represents the value of the element whose presence has to be checked in the Set object. Return: It returns true if the specified element is in the set otherwise returns false. Example: <!DOCTYPE html> <html> … Read more

Set forEach() JavaScript

The JavaScript Set forEach() method executes the specified function once for each value. Syntax: setObj.forEach(callback(currentValue, currentKey, Set)) { // code to be executed } Parameters: callback: It represents the function to be executed for each element, taking three arguments: (currentValue, currentKey, and set). thisArg: It represents this keyword for the function. Example: <!DOCTYPE html> <html> … Read more

Set delete() JavaScript JS

The JavaScript Set delete() method deletes or removes only the selected elements from the Set object. Syntax: setObj.delete(value) Parameters: value: It represents the value of the specified property to be deleted. Return: It returns true if the specified element is deleted or removed successfully otherwise, it returns false. Example: <!DOCTYPE html> <html> <body> <script> var … Read more

Set clear() JavaScript

The JavaScript Set clear() method clears or removes all the elements from the Set object. Syntax: setObj.clear() Example: <!DOCTYPE html> <html> <body> <script> var jewels = new Set(); jewels.add(“DIAMOND”).add(“GOLD”).add(“PLATINUM”).add(“SILVER”); for (let i of jewels) { document.write(i+”<br>”); } jewels.clear(); document.write(jewels.size); </script> </body> </html>

Reflect.setPrototypeOf() JavaScript

The JavaScript Reflect.setPrototypeOf() method sets the prototype of an object to another object. It is similar to Object.setPrototypeOf(). Syntax: Reflect.setPrototypeOf(target, prototype) Parameters: target: It represents the object whose prototype has to be set. prototype: It represents the object’s new prototype. Return: It returns true if the object’s new prototype is set successfully otherwise, it returns … Read more

Reflect.set() JavaScript JS

The JavaScript Reflect.set() method sets the value of the property of an object. Syntax: Reflect.set(target, propertyKey, value[, receiver]) Parameters: target: It represents the object on which to set the property. propertyKey: It represents the name of the property to set. value: It represents the value of the set corresponding to the specified property. receiver: It … Read more

Reflect.preventExtensions() JavaScript

The JavaScript Reflect.preventExtensions() method prevents any future extensions to an object i.e. prevents addition and modification of properties. It is It is similar to Object.preventExtensions(). Syntax: Reflect.preventExtensions(target) Parameters: target: It represents the object that prevents extensions. Return: It returns true if the target object was successfully set to prevent extensions otherwise returns false. Note: It … Read more

Reflect.ownKeys() JavaScript JS

The JavaScript Reflect.ownKeys() method gives an array whose values represent the keys of the properties of an object. It includes only the object’s direct properties. Syntax: Reflect.ownKeys(target) Parameters: target: It represents the object from which to get the own keys. Return: It returns an array of the target object’s own property keys. Note: It throws … Read more