Home HTML CSS JAVASCRIPT BOOTSTRAP Python Docker ML tutorial About us Privacy policy

String Methods and properties



String Methods and properties



length property

In javaScript if we want to count the length of the string then we use length property of the string..




indexOf() Method

By using indexOf() function we can find string inside the string.


lastIndexOf() Method

By using lastIndexOf() method we can get last occurs of the given string.


search() Method

In javaScript if we want to search string inside a given string then we use search() method of a string. searchO() returns first occurance of the given string.


slice() Method

slice() method returns a particular slice or part of the string according to our requirement.slice method can also accept negative values.


substring() Method

substring() is similar to slice() method ,the only difference is slice () method can accept negative values also but substring() can not accept negative values.

substr() Method

substr() method is similar to the slice() method,the only difference is second parameter specifies the length of the given string.


replace() Method

replace() method is use to replace a given string in a javascript.


By default replace() method can replace first match of the string only,if ther is another mathch of string is available then replace() does not replace the value.


Converting Upper and lower case

If you want to convert a string to a upper case then we use toUpperCase() method.


we can also convert a given string to a lower case by using toLowercase() method.


concat() Method

If we want to add two string then we use concat() method of string.


trim() Method

trime() method is use to remove whitespaces of a string from both sides.


charAt() method

charAt() method is use to return charcters at a specified index.

charCodeAt() method

charCodeAt() is ue=se to return unicode of the character at a specified index position.


split() Method

split() method is generally use to convert string to an array.