String Functions in JavaScript

String Functions in JavaScript
Rating: 5 - 1 Votes

String Functions in JavaScript

JavaScriptWe have couple of functions to manipulate strings in JavaScript.  Mostly commonly used functions are given below with example.

toUpperCase():  This function will change the case of a string to upper.

toLowerCase():  This function will change the case of a string to lower.

trim():  This function will remove any extra white space at the start and end of a string.

replace():  This function will replace any value in a string.  It will take 2 parameters, old value and new value.  It will basically search for old value in a string and perform the replacement.  You can also pass regular expression as parameter instead of old value.

length:  This is not a function but a property which will return the length of a string.