JavaScript String (Part-1)

Keya Mallick
Nov 2, 2020

1. Javascript String charAt()

The charAt() method that finds out the character at the specified index in a string.

Syntax- string.charAt(index)

Example-

  • If you want finds out the last character in a string then the

Syntax- str.charAt(str.length-1)

Example-

2. Javascript String concat()

The concat() method Join two or more strings.

Syntax- str.concat(string2[, string3, …, stringN])

Example-

3. Javascript String endsWith()

The endsWith() method checks whether a string ends with the characters of a specified string.

Syntax- string.endsWith(searchvalue, length)

  • This method returns the boolean type(true, false)

Example-

4. Javascript String startsWith()

The endsWith() method checks whether a string ends with the characters of a specified string.

Syntex- string.startsWith(searchvalue, start)

  • This method returns the boolean type(true, false)

Example-

5. Javascript String indexOf()

The indexOf() method is used to search the index position in a given String.

Syntax- string.indexOf(searchvalue, start)

  • If it is not found when it returns -1
  • The indexOf() method is case sensitive.

Example-

6. Javascript String lastIndexOf()

The lastIndexOf() method is used to search the last index position in a given String.

Syntex- string.lastIndexOf(searchvalue, start)

Example-

7. Javascript String lastIndexOf()

The replace() method is replacing old char with new char.

Syntex- string.replace(searchvalue, newvalue)

Example-

8. Javascript String slice()

The slice() method extracts parts of a string.

Syntex- string.slice(start, end)

Example-

9. Javascript String split()

The split() method is used to split the given string into an array.

Syntex- string.split(separator, limit)

Example-

10. Javascript String trim()

The trim() method removes whitespace from both sides of a string.

Syntex- string.trim()

Example-

--

--