String methods help you to work with strings. I have curated a list with 8 common methods which you can come across in every code. Now let's get our hands dirty by looking at some code.

1. touppercase() & tolowercase()

A string is converted to upper case with toUpperCase() and to lower case withtolowercase().

let a = "Kaarthik";
console.log(a.toUpperCase());  // a is converted to uppercase -> KAARTHIK

let b = "SEkaR";
console.log(b.toLowerCase()); // b is converted to lowercase -> sekar

2. String.length()

The length property returns the length of a string:

let name = "Kaarthik";
console.log(name.length); // 8

3. string.slice()

The slice() extracts a part of a string and returns the extracted part in a new string and it also returns the shallow copy which you can save in a new variable.

syntax:

slice(start, end)

Now let's see an example,

let str = ['apple','Mango','Orange'];
console.log(str.slice(0,1)); // Array [ "apple" ]

4. string.substring()

The substring() method returns the part of the string between the start and end indexes, or to the end of the string.