String Object in Javascript
String Object in Javascript
1) A JavaScript string stores a series of characters.
for example "Pune university"
2)A string can be any text inside double or single quotes.
for example "Pune university" or 'Pune university'
3)String indexes are zero-based:
The first character is in position 0, the second in 1, and so on.
Property :
length:
length property return the number of character in a string.
for example
var str="Mumbai";
document.write("The Length is"+str.length);
OUTPUT: 6
Method :
1)charAt()
2)indexOf()
3)lastIndexOf()
4)substr()
5)substring()
6)trim()
7)toLowerCase()
8)toUpperCase()
1)charAt()
return the character at the specified position (in number).
for example:
var str = "HELLO WORLD";
document.write("The character position is"+str.charAt(0));
output :
H
2)indexOf()
3)lastIndexOf()
4)substr()
5)substring()
6)trim()
7)toLowerCase()
8)toUpperCase()
let text = "HELLO WORLD";
let letter = text.charAt(0);
Comments
Post a Comment