Js common operating string

  var str = " Hello World ";

  str.toUpperCase (); // convert a string to upper case

  str.toLowerCase (); // string to lowercase

  str.indexOf ( "World"); // index string exists if the first letter of the index position of the index returns -1 otherwise if the string is "" Returns 0

  str.concat ( "Tonight Night", "Mami"); // in the method of the string sequentially added to the string

  str.slice (2,4); // taken preamble index starts at the post but does not contain an index

  str.slice (-4, -2); // if the index is negative reverse order

  str.substring (5,2); // will automatically distinguish between the start and end positions according to the index value of the size

  str.substring (-4, -2); // index when the value is negative, then all converted to 0

  str.substr (2,3); // before the start parameter refers to the index of the index value, the length of the index parameter is

  str.split ( "", 1); // before division based on the reference characters, and then dividing the value stored in the array returned completely to determine the length of the array in accordance with the parameters

  str.trim (); // remove both spaces string

  

Guess you like

Origin www.cnblogs.com/tanghao22/p/11892380.html