String Functions
Usually the string is defined with in single quote or double quote in JavaScript/jQuery, in jQuery have some built in methods to manipulate the string.Types
charAt()
toUpperCase()
toLowerCase()
replace()
split()
i)charAt
Find the character position from given string.
var str="Allinworld99";
var str_val=str.charAt(3); //It returns i
ii)toUpperCase
Convert the given string to upper case letters.
var str="Allinworld99";
var str_val =str.toUpperCase(); //It returns ALLINWORLD99
iii)toLowerCase
Convert the given string to uppercase letters.
var str="ALLINWORLD99";
var str_val =str.toLowerCase(); //It returns allinworld99
iv)replace
This method is used to replace word/character by another word/character.
var str="3inworld99";
var str_val=str.replace("3","All"); //It returns Allinworld99
v)split
This method is used to split the string by using a delimiter and push it into an array.
var str="A,L,L,I,N,W,O,R,L,D";
var X=str.split(","); //It returns ["A","L","L","I","N","W","O","R","L","D"]
Example Program:- (Editor)
Editor is Loading...
Advertisement
0 comments:
Post a Comment