Object.freeze() JavaScript

The JavaScript Object freeze() method prevents existing properties from being modified and the new properties from being added on the specific object. Syntax: Object.freeze(object) Parameters: object: It represents the object on which new properties are to be added or modified. Return: Given object. Example: <!DOCTYPE html> <html> <body> <script> const obj = { prop: 56 … Read more

Object.entries() JavaScript

The Javascript Object entries() method gives an array with enumerable property key-value pairs of a specified object. Syntax: Object.entries(object) Parameters: object: It represents the object whose enumerable property key-value pairs have to be get. Return: An array with enumerable property key-value pairs. Example: <!DOCTYPE html> <html> <body> <script> const a = { 10: ‘BRONZE’, 20: … Read more

Object.defineProperties() JavaScript JS

The Javascript Object defineProperties() method is used to add or modify multiple object properties. Syntax: Object.defineProperties(object, properties) Parameters: object: It represents the object on which multiple properties have to be added or modified. properties: It represents the properties that have to be added or modified. Return: Modified object. Example: <!DOCTYPE html> <html> <body> <script> const … Read more

Object.defineProperty() JavaScript

The Javascript Object defineProperty() method describes the behavioral attributes of the property. It is used to add a new property or change or modify an existing property directly to a specified object and returns the object. Syntax: Object.defineProperty(object, property, descriptor) Parameters: object: It represents the object to which the new property will be defined. property: … Read more

Object.create() JavaScript

The Javascript Object create() method creates a new object with the specified prototype object and properties. Syntax: Object.create(prototype[, propertiesObj] Parameters: prototype: It represents the target object. It is a required parameter. propertiesObj: It represents enumerable properties that will be added to a newly created object. It is an optional parameter. Return: A new object with … Read more

Object.assign() JavaScript

The Javascript Object assign() method copies enumerable and own properties from a source object to a target object. The whole operation (assignment and copy) is done by reference. Syntax: Object.assign(target, sources) Parameters: target: It represents the target object. source: It represents the source object. Return: It returns the target object. Example: <!DOCTYPE html> <html> <body> … Read more

JavaScript RegEx test() method

The JavaScript RegExp test() method is used to search for a match between a regular expression and a specified string. Syntax: RegExpObject.test(string); Parameters: string: It represents the string to be searched. Return: It returns true if the match between a regular expression and a specified string is found otherwise returns false. Example: <!DOCTYPE html> <html> … Read more

JavaScript RegEx exec()

The JavaScript RegExp exec() method is used to get an array containing all the matched groups for a specified string. Syntax: RegExpObject.exec(string) Parameters: string: It represents the string to be searched. Return: An array containing all the matched groups for a given string. Example: <!DOCTYPE html> <html> <body> <script> var string = “HELLO WORLD”; var … Read more

JavaScript RegExp tutorial

A regular expression refers to the object which represents the pattern of characters. JavaScript provides the RegEx class which provides the pattern-matching and search-and-replace functionality on text. Syntax: /pattern/modifiers Modifiers Modifiers are used to perform case-insensitive and global searches. Modifier Description g It is used to find all matches. i It is used to perform case-insensitive … Read more