Latest News

String Functions in Javascript,String Functions,Java script String Functions


String functions:
These functions will work only on strings.
Length: It written the length of the string.
Syntax: string name.length
toUpperCase: convert the string into upper case.
Syntax: string name.toUpperCase
toLowerCase: convert the string into lower case
syntax: string name.toLowerCase
indexOf: It written the index or position of a character.
Syntax: string name.indexOf(character,string index)
NOTE: if character not found it written -1.
lastIndexOf: It written the position of character from last occurrence.
Syntax: string name.lastIndexOf(character,string index)
Example:
var str=”this is sample string”;
document.write(str.lenght)
CharAt: It written CharAt specified Index.
Syntax: string name.CharAt(Index)
Example: document.write(str.CharAt(2));
CharcodeAt: It returns array number of character at specified index.
Syntax: document.write(str.CharCodeAt(8));
ConCat: It is used to combain 2 or more strings.
Syntax: string name.ConCat(string2,string3)
Example:
var str2=”test”;
var str3=”test1”;
document.write(str2.ConCat(str,str3));
Match: It is used to search a value in specified string, if value found it written values, when value not found it written null.
Syntax: string name.Match(value)
Example: document.write(str.match(‘is’));
Search: It is also used to search a character or word or value, if character found it returns index of the character, when character not found, it written -1.
Syntax: string name.search of value
Example: document.write(str.search(‘is’));
Replace:  It is used to replace old string into new string in specified string, But it replace only one occurrence.
Syntax: string name.replace(old string,new string)
Example: document.write(str.replace(‘is’,’test’));
Substring: it is used to get sub string from main string.
Syntax: string name.substring(starting index,ending index)
Example: document.write(str.substring(10,16));
SubStr: It is also similar to substring function.
Syntax: string name.substr(starting index,number of char)
Example: document.write(str.substr(10,6));
Srtingname.big: applying big tag to string
Example: document.write(str.big()+”<br>”);
Stringname.small: Applying small tag to  string.
Example: document.write(str.small()+”<br>”);
String.blod: Applying bold tag to string.
Example: document.write(str.bold()+”<br>”);
String.italic: Applying italic tag to string.
Example: document.write(str.italic()+”<br>”);

No comments:

Post a Comment

eWeb Classes Powered by MV Innovative InfoTech Copyright © 2014

Theme images by Bim. Powered by Blogger.