ES5 new method of testing an array of strings and common API test

The first is the method of testing an array of new ES5:

<! DOCTYPE HTML>
<HTML lang = "EN">
<head>
<Meta charset = "UTF-. 8">
<title> the Document </ title>
</ head>
<body>

</ body>
<Script>
// ARR = var [1,2,6,3,4,5,6,7];
// var arr.indexOf I = (6,3);
// the console.log (I);
// return for a array or predetermined position of the character string or strings

ARR = var // [1,2,6,3,4,5,6,7];
// arr.forEach (function (value, index, ARR) {
// the console.log (value, index, ARR) ;
//})
// forEach loop through the array, the function representing the three parameters, the value of the index, the array itself, there is no return value is undefined

// map will traverse the current array and then calls the method parameters, return to the current method's return value;
// map does not change the original array, but the function is executed after a return value to form a new array, return it
/ / var ARR = [1,2,6,3,4,5,6,7];
// var newArr = arr.map (function (value, index, ARR) {
// return-value. 1;
// / / returns a new array
//})
// the console.log (newArr);

ARR = var // [1,2,6,3,4,5,6,7];
// arr.filter (function (value, index, ARR) {
// the console.log (value, index, ARR) ;
//})
// .filter (the callback); map with the method returns a Boolean value of true when the data is returned to the application
// var arr = [1,2,6,3,4,5,6 ,. 7];
// var newArr = arr.filter (function (value, index, ARR) {
// return value>. 3;
// // will return a value determined as a true output, to filter out false, this is a unique filter where
//})
// the console.log (newArr);
// // final output through a new array newArr screened;
</ Script>
</ HTML>

 

The following is a common API test string:

<! DOCTYPE HTML>
<HTML lang = "EN">
<head>
<Meta charset = "UTF-. 8">
<title> the Document </ title>
</ head>
<body>

</ body>
<Script>
var STR = "helleo";
// var str.indexOf V = ( "E",. 3);
// the console.log (V);
// return a string or an array or string of characters in a predetermined position;

The console.log // (str.charAt (. 4));
// Returns the specified character position, index as subscript

// (str.substr (n, m)) the console.log;
// returns a string containing m from the specified position n, to the end position, the end position is not specified if, from the start position to the end

// (str.substring (n, m)) the console.log;
// return string (excluding) m from the specified position n, to the end position, the end position is not specified if, from the start position to the end

The console.log // (str.slice (2,5));
// with the substring, the array should be noted that the method and slice () is similar to

The console.log // (str.split ( "E"));
// specified by the character string dividing returns an array [ "h", "ll" , "o"]

the console.log (str.replace ( "E", "P"));
// Replace ( "needs to be replaced character string", "after the replacement string") // will replace some of the character string to another some characters. Is preferably used with a regular
</ Script>
</ HTML>

Guess you like

Origin www.cnblogs.com/liguanlong/p/11388291.html