Nothing else, consolidate the foundation under ...
String:
String Split split ()
String interception slice ()
Alternatively string replace ()
var STR = "Test, Entity" ;
the console.log ( "string ******* *********" );
// string split into an array
console.log ( "split: ", str.split (", " ));
// string interception
// substr (start index, the number of bits taken), can be taken from the tail, a negative index, end -1
// Slice second parameter may be omitted, from the specified location to the final cut
the console.log ( "substr1:", str.substr (5,3 ));
the console.log ( "substr2:", str.substr (-3,3 ));
the console.log ( " slice1: ", str.slice (0,4 ));
the console.log ( " slice2: ", str.slice (. 4 ));
Console.log("slice3:",str.slice(-6));
// search for a string index, indexOf is the first time, lastIndexOf last appearance, can not be found or -1
// can set the second parameter to start looking at the specified location, indexOf from left to right, lastIndexOf from right to left
the console.log ( "the indexOf:", str.indexOf ( "T" ));
the console.log ( "the indexOf:", str.indexOf ( "T",. 5 ));
the console.log ( "lastIndexOf: ", str.lastIndexOf (" T " ));
the console.log ( " lastIndexOf: ", str.lastIndexOf (" T ", 2 ));
// search string, returns the index, there is no or -1, can use regular
the console.log ( "serach1:", str.search ( "Test" ));
the console.log ( "serach2:", STR.Search (/ [1-9] / G));
// string replacement (the "replace", "replace")
the console.log ( "Replace:", str.replace ( "Entity", "String" ));
// string concatenation can be connected to a plurality of equivalent strings plus Usage
console.log ( "concat:", str .concat ( ", App", ", Web" ));
var ARR = [ "A", "B", "C" ];
// array to a string that can be specified spacer
console.log ( "join1: " , arr.join ());
the console.log ( " join2: ", arr.join (" - " ));
// toString logic value to a string
the console.log (" toString1: " , arr.toString ());
console.log ( "toString2:", to true .toString());
var obj = {"name":"jiangnan"};
// JSON string type turn
the console.log ( "the stringify:" , the JSON.stringify (obj));
// parse
var objStr = the JSON.stringify (obj);
the console.log ( "the parse:", the JSON.parse ( objStr));
Run as follows:
Array:
Find element position indexOf ()
Delete the last element pop ()
Delete first element shift ()
Adding new elements push ()
Connect the new array concat ()
Object:
Merging objects Object.assign (obj1, obj2, obj3)