concat() JavaScript JS

The JavaScript string concat() method retrieves a combination of two or more strings. Original strings will not be modified. Syntax: string.concat(string1,string2,…) Parameters: string1,string2,…: Represents the different strings to combined. Return: New string after the combination of strings. Example: <!DOCTYPE html> <html> <body> <script> document.writeln(“HELLO”.concat(” WORLD!”)); </script> </body> </html>

JavaScript String charCodeAt() method

The JavaScript string charCodeAt() method retrieves the Unicode value of a character present at the specified index. Index can be from 0 to n-1 where n is the size of the string. It will return an integer value between 0 and 65535. Syntax: string.charCodeAt(index) Parameters: index: It represents the specified position of a character. Return: … Read more

charAt String JavaScript

The JavaScript string charAt() method retrieves the char value present at the specified index. If n is the size of the string then the index can be from 0 to n-1. Syntax: String.charAt(index) Parameters: index: It represents the specified position of a character. Return: Char value present at the specified index. Example 1: <!DOCTYPE html> … Read more

Set values() JavaScript

The JavaScript Set values() method gives an object of Set iterator that contains the values for each element. It is similar to the keys() method of Map. Syntax: setObj.values() Return: Iterator object. Example: <!DOCTYPE html> <html> <body> <script> var jewels = new Set(); jewels.add(“DIAMOND”).add(“GOLD”).add(“PLATINUM”).add(“SILVER”); var gems =jewels.values(); document.writeln(gems.next().value+”<br>”); document.writeln(gems.next().value+”<br>”); document.writeln(gems.next().value+”<br>”); document.writeln(gems.next().value); </script> </body> </html>

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>