String Functions:

1) String length: To count the string length.

Code:




Output:




2) String Index: It represents the position of element in the string starting from 0 to length-1.

The IndexOf() returns position of first occurrence of specified sub string in the string.
The charAt() returns the character at specified index of string.

Code:



Output:



3) Search for a string in a word:In JavaScript, search() is used to search a string for specified value.

It returns the position of matching string otherwise it returns -1.

Code:



Output:




4) Substring: The substring() returns characters from a string between start and end indices but not including end.

The substr() returns substring from the specified index to specified length.

Code:



Output:




5)String Replace: The replace() searches for a substring in the given string and then replace with new string.


Code:



Output:



After clicking the button:




6) String Lowercase and Uppercase:

The toLowerCase() returns lower case letter characters of string.
The toUpperCase() returns upper case letter characters of string.

Code:



Output:




7) String trim and cut: 
The trim() removes the white spaces from a string.
The slice() is used to extract the part of string.

Code:



Output: