Array.prototype.forEach(<callbackFn>,<this>) Execute a provided function once per array element.

Array.prototype.map(<callback>) Use a callback function to transform an array into another array.

Array.prototype.reduce(<callbackFn>,<initialValue>) Apply a function against an accumulator and each value of the array (from left-to-right) to reduce it to a single value.

Array.prototype.sort(<comparator()>) Sorts the elements of an array in place using an optional comparator function and returns the array.

Facts, Thoughts and Opinions


An algorithm to extract the distinct values from an array.

var index = {}, distinct = [], i, datum;
for (i = 0; i < this.length; i++) {
    datum = this[i]; // modify this as needed
    if (!index[datum]) {
        index[datum] = true;
return distinct;

Select random element from array (JavaScript)

value = myArray[Math.floor(Math.random() * myArray.length)];


  •   Subtopics

  •   Writings

  Sources & Bookmarks