① Number type
Number type has some static properties ( properties called directly from number , without the new operator ) and Methods .
var box = 1000.789;//alert (Box.tostring ()),//Convert to a string, the argument can be converted into//alert (box.tolocalestring ());//local form, 1,000.789// Alert (box.tofixed (2));//1000.79, reserved two decimal places, rounded//alert (box.toexponential ());//exponential form, 1.000789e+3//alert ( Box.toprecision (8));//1.00e+3, exponent or point form, selected according to parameters
② String type
var box = ' Asbdfghjkla ';//alert (Box.indexof (' B '));//2, returns the index value of B//alert (Box.indexof (' d ', 2));//3//alert ( Box.lastindexof (' a '));//10//alert (Box.lastindexof (' a ', 9));//0, searching forward from the specified position
/* Not found return-1, example: Find all a*///var box = ' Asbdfghjkla ';//var Boxarr =[];//Store An array of position a//var pos =box.indexof (' a ');//Get the position of the first A// while (Pos >-1) {//greater than-1, indicates the presence of a//Boxarr.push (POS);//Add to Array// pos = Box.indexof (' A ', pos + 1);//re-assign POS current position// }//alert (Boxarr);//0,10
JavaScript Basic Wrapper type