1.method of the string object (1)--Case Conversion
var str1= "ABCD"
var str2=str1.tolowercase ();//"ABCD"
var str2=str1.touppercase ();//"ABCD" var str1= "Welcome to the world of js!";
2.method of String Object (2)--Retrieval of characters
var str1= "Welcome to the world of js!";
var str2=str1.indexof ("L");//starting from 0, the result is 2;
var str3=str1.lastindexof ("L"), starting from 0, with a result of 18;
var str2 = Str 1 . Match ("World");//used to find the string
var Str 3 = Str 1 . Match ("World");//The first character position index used to match a string
Alert (str2[0]); //Results are " World " ;
alert (STR3);//The result is 15;
Method of 3.String Object (3)--substring processing
Calculate substring length
var str1= "ABcd EFGHJ "
Console.log (str1.length);//Calculation length
Console.log ( substr (str1. (1,4));//x.substr (start, length) results "Bcde"
Console.log ( substring (str1. (1,4));//x.substr (start, end) result "Bc"
var str2=str1.slice (2,4);
var str3=str1.slice (4);
var str4=str1.slice (2,-1);
var str5=str1.slice ( -3,-1);
alert (STR2);
The result is "CD"
alert (STR3);
The result is "EFGH"
alert (STR4);
The result is "CDEFG"
alert (STR5);
The result is "FG"
Review of the day before JS