JavaScript String Functions With Example
JavaScript short name (JS) is a dynamic programming language. It can provide the dynamic interactivity on websites when it applied with HTML documents.
It was developed by Brendan Eich, co-founder of the Mozilla project, the Mozilla Foundation, and the Mozilla Corporation.

Below is the list of JavaScript string functions.
SN | String Function | Example |
---|
1 | trim() | | var s1="FreeWeb Mentor"; var s2=s1.trim(); document.write(s2); |
|
2 | charAt(index) | | var myString = 'jQuery FTW!!!'; console.log(myString.charAt(7)); |
|
3 | concat(str) | | var message="Hello" var finalWord=message.concat("This is a"," Cat.") //output: Hello This is a Cat alert(finalWord); |
|
4 | lastIndexOf(str) | | var myString = 'FreeWeb Mentor'; //Output is 13 console.log(myString.lastIndexOf('r')); |
|
5 | indexOf(str) | | var sentence="Hi, my name is Prem!" if (sentence.indexOf("Prem")!=-1) alert("Prem is in there!"); |
|
6 | toLowerCase() | | var s1="Javascript Example"; var s2=s1.toLowerCase(); alert(s2); |
|
7 | toUpperCase() | | var s1="Javascript Example"; var s2=s1.toUpperCase(); alert(s2); |
|
8 | slice(beginIndex, endIndex) | | var text="freewebmentor"; text.slice(0,6); //returns "freewe" text.slice(2,6); //returns "eewe" |
|
9 | split(delimiter, [limit]) | | var message="Welcome to FreeWebMentor!" var word=message.split("l") |
|
If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected]
Your article will appear on the FreeWebMentor main page and help other developers.
Recommended Posts:
An engineer by profession and a passionate blogger by heart. Founder of FreeWebMentor.com (A Programming blog for beginners), Tech Speaker at various forums. A part from this he is an open source enthusiast, WordPress Lover, Blogger, SEO, and Growth Strategic.
Article Tags: javascript function return string, javascript string function, javascript tutorials, string functions javascript, string manipulation functions in javascript