//1.charAt() returns the character at the specified position.

var anyString = “Brave new world”;

console.log(“The character at index 0 is ‘” + anyString.charAt(0) + “‘”);

//The character at index 0 is ‘B’

//2,charCodeAt() returns the Unicode encoding for the character at the specified position.

const sentence = ‘The quick brown fox jumps over the lazy dog.’;

const index = 4;

console.log(The character code ${sentence.charCodeAt(index)} is equal to ${sentence.charAt(index)});

// expected output: “The character code 113 is equal to q”

//3.match() finds matches for one or more regular expressions. Returns an array of matched values

const paragraph = ‘The quick brown fox jumps over the lazy dog. It barked.’;

const regex = /[A-Z]/g;

const found = paragraph.match(regex);

console.log(found);

// expected output: Array [“T”, “I”]

//4.replace() The first argument is the value to be matched, the second argument is the value to be replaced, the original string is not changed, and a new string is returned

var p = ‘The quick brown fox jumps over the lazy dog. If the dog reacted, was it really lazy? ‘;

var s = p.replace(‘dog’, ‘monkey’);

console.log(s)

// expected output: “The quick brown fox jumps over the lazy monkey. If the dog reacted, was it really lazy?”

var regex = /Dog/ig;

var s = p.replace(regex, ‘monkey’);

console.log(s) // expected output: “The quick brown fox jumps over the lazy ferret. If the ferret reacted, was it really lazy?”

//5.search() retrieves the value that matches the regular expression. If the match is successful, search() returns the index of the first regular expression match in the string; Otherwise, -1 is returned.

const paragraph = ‘The quick brown fox jumps over the lazy dog. If the dog barked, was it really lazy? ‘;

// any character that is not a word character or whitespace

const regex = /[^\w\s]/g;

console.log(paragraph.search(regex)); // expected output: 43

console.log(paragraph[paragraph.search(regex)]); // expected output: “.”

// 6.tolocalelowerCase () converts the called string to a new string in lowercase format according to any locale-specific case mapping rules. The return value is a new string

‘ALPHABET’.toLocaleLowerCase(); // ‘alphabet’

// 7.toLocaleUpperCase() converts the string to uppercase. As’ alphabet. ToLocaleUpperCase (); // ‘ALPHABET’

Var anyString = “Mozilla”; //8. Substring () extracts the character between two specified index numbers in the string and returns a new string var anyString = “Mozilla”;

// output “Moz” console.log(anystring.substring (0,3));

//9.substr()

The console. The log (‘ findCommonPrefix. Substr (2, 6)); // The first argument is extracted from the index number, and the second argument is extracted from the number of characters

The console. The log (‘ findCommonPrefix ‘. The substring (2, 6)); // From the first parameter to the second parameter, excluding the second parameter

The trim() method removes whitespace characters from both ends of a string. // The return value is a new string representing whitespace at both ends of the calling string. const greeting = ‘ Hello world! ‘;

console.log(greeting); // expected output: ” Hello world! “;

console.log(greeting.trim()); // expected output: “Hello world!” ;