Worked for a period of time, also summed up some JS commonly used programming skills. If something is wrong, please correct it.

  1. Gets the elements of the array randomly.

    Var arrays = [1, 2, 3, 4, 5];

    var arrayItem = arrays[ Math.floor( Math.random() * arrays.length ) ];

  2. Gets a random number in a specified range.

    var x = Math.floor( Math.random() * Max – Min + 1) + min;

  3. Generates a random string of letters and numbers.

    function ( stringLength ) {

    var x = “”;

    for ( ; x.length<stringLength; x += Math.random().toString(36).subStr(2) );

    rerturn x.subStr(0,stringLength);

    }

  4. Generates an array of numbers from 0 to the specified value.

    var arrays = [ ], max = 100;

    for(var i=0; arrays.push(i++) < max; ) ;

  5. Verify whether it is a number.

    function checkNmuber (n) {

    return ! isNaN(parseFloat(n)) && isFinite(n);

    }

  6. Gets the maximum or minimum value in the array.

    Var arrays =,2,3,44,55,76,88,23 [1];

    var maxN = Math.max.apply(Math , arrays);

    var minN = Math.min.apply(Math , arrays);

  7. Empty the array.

    Var arrays = [1, 2, 3, 4, 5];

    arrays.length = 0; // Arrays = [] because length is a writable property.

  8. Truncate the array with length.

    Var arrays = [1, 2, 3, 4, 5];

    arrays.length = 2; // when the arrays = [1,2], if the array length is larger than the original length value, the array length will be increased, and undefined will be added to the array.

  9. Append between arrays.

    Var arrays1 = [1, 2, 3, 4, 5], arrays2 =,7,8,9,10 [6];

    Array.prototype.push.apply(arrays1,arrays2); Array1 = [1,2,3,4,5,6,7,8,9,10]; Array appending is also possible with the concat method for arrays.

  10. Verify that it is an array.

    function isArray (obj) {

    return Object.prototype.toString.call(obj) === ” [object Array] “;

    }

    // Array.isArray(obj); You can also check if it’s an array.