Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

JavaScript String Functions With Example

javasrcipt functions

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.

javasrcipt functions

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")

The post Javascript String Functions With Example appeared first on FreeWebMentor.



This post first appeared on Programming Blog Focused On Web Technologies, please read the originial post: here

Share the post

JavaScript String Functions With Example

×

Subscribe to Programming Blog Focused On Web Technologies

Get updates delivered right to your inbox!

Thank you for your subscription

×