➢String indexOf()
➢String lastIndexOf()
➢String startsWith()
➢String endsWith()
➢The indexOf() method returns the index of (the position of) the first occurrence of a specified text in a string:
EXAMPLE:
let Name = "Susindra Reddy";
Name.indexOfName("Reddy");
➢The lastIndexOf() method returns the index of the last occurrence of a specified text in a string:
EXAMPLE:
let Name = "Susindra Reddy";
Name.lastindexOfName("Reddy");
➢The search() method searches a string for a specified value and returns the position of the match:
EXAMPLE:
let Name = "Susindra Reddy";
Name.search("Reddy");
➢The match() method searches a string for a match against a regular expression, and returns the matches, as an Array object.
EXAMPLE:
let Name = "Susindra Reddy";
Name.match(/ddy/r);
➢The includes() method returns true if a string contains a specified value.
EXAMPLE:
let Name = "Susindra";
Name.includes("Reddy");
➢The startsWith() method returns true if a string begins with a specified value, otherwise false:
EXAMPLE:
let Name = "Susindra";
Name.startsWith("B");
➢The endsWith() method returns true if a string ends with a specified value, otherwise false:
EXAMPLE:
let Name = "Susindra";
Name.endsWith("Reddy");
EXAMPLE:
let Name = "Susindra";
Name.endsWith("Reddy", 9);