String Methods in ES6

String Methods in ES6

  • String.includes()

The includes() method returns true if a string contains a specified value, otherwise false:

  • String.startsWith()

The startsWith() method returns true if a string begins with a specified value, otherwise false:

  • String.endsWith()

The endsWith() method returns true if a string ends with a specified value, otherwise false:

let text = “Hello guys, welcome to my tutorial.”;

text.includes(“guys”)   

text.startsWith(“Hello”)  

text.endsWith(“tutorial “) 

The For/Of Loop

The JavaScript for/of statement loops through the values of an iterable objects.

let marks = [80, 90, 70];

for (let mark of marks) {

    console.log(score);

}

3 thoughts on “String Methods in ES6

Post Your Comments & Reviews

Your email address will not be published. Required fields are marked *

*

*