Core Docs | Additional Modules Docs
@Description: Returns the array value of the key we are currently on as referenced by the pointer. Starts at 0 and chanegs base don use of next(), prev(), rewind(), end()
@File: Array/prototype/iteration.js
@Example:var myArray = [1,10,2,3,4,5];
myArray.current(); //returns 1 at first
//after manipulations it changes reference based on the pointer
myArray.next();
//now it is the next one
myArray.current(); //returns 10
@Description: Returns the array value of the last key and sets the array's pointer to that key
@File: Array/prototype/iteration.js
@Example:var myArray = [1,10,2,3,4,5];
myArray.end(); //sets the pointer to the last array key and returns the value, in this case 5
@Description: Returns the first value in the array without moving the pointer.
@File: Array/prototype/iteration.js
@Example:var myArray = [1,10,2,3,4,5];
myArray.first(); //returns 1
@Description: Returns the last value of the array without moving the pointer.
@File: Array/prototype/iteration.js
@Example:var myArray = [1,10,2,3,4,5];
myArray.last(); //returns 5
@Description: Returns the next value of the array and moves the pointer forward to it.
@File: Array/prototype/iteration.js
@Example:var myArray = [1,10,2,3,4,5];
myArray.current(); //returns 1
myArray.next(); //returns 10
myArray.current(); //returns 10
@Description: Used to keep track of the array key we are referenceing with next, prev, end, current, rewind
@File: Array/prototype/iteration.js
@Description: Returns the next value of the array and moves the pointer forward to it.
@File: Array/prototype/iteration.js
@Example:var myArray = [1,10,2,3,4,5];
myArray.end(); //returns 5
myArray.prev(); //returns 4
myArray.current(); //returns 4
@Description: This emulates Array.prototype.reduce from javascript 1.6 and is taken from the MDC site reference. .reduce executes the callback function once for each element present in the array, excluding holes in the array, receiving four arguments: the initial value (or value from the previous callback call), the value of the current element, the current index, and the array over which iteration is occurring.
The call to the reduce callback would look something like this:
@File: Array/prototype/reduce.js
@Author: Paul Visco
@Version: 1.1 11/19/07
@Param: function The function to apply the array elements to
@Example:myArray.reduce(function(previousValue, currentValue, index, array){
// ...
});
//real examples
var total = [0, 1, 2, 3].reduce(function(a, b){ return a + b; });
// total == 6
var flattened = [[0,1], [2,3], [4,5]].reduce(function(a,b) {
return a.concat(b);
}, []);
// flattened is [0, 1, 2, 3, 4, 5]
@Description: This emulates Array.prototype.reduceRight from javascript 1.6 and is taken from the MDC site reference. .reduceRight executes the callback function once for each element present in the array, excluding holes in the array, receiving four arguments: the initial value (or value from the previous callback call), the value of the current element, the current index, and the array over which iteration is occurring.
The call to the reduce callback would look something like this:
@File: Array/prototype/reduceRight.js
@Param: function The function to apply the array elements to
@Example:myArray.reduceRight(function(previousValue, currentValue, index, array){
// ...
})
//real examples
var total = [0, 1, 2, 3].reduceRight(function(a, b) { return a + b; });
// total == 6
var flattened = [[0, 1], [2, 3], [4, 5]].reduceRight(function(a, b) {
return a.concat(b);
}, []);
// flattened is [4, 5, 2, 3, 0, 1]
@Description: Returns the first value of the array and moves the pointer back to the beginning.
@File: Array/prototype/iteration.js
@Example:var myArray = [1,10,2,3,4,5];
myArray.rewind(); //returns 1
@Description: Used to determine the average value from an array of values
@File: Array/prototype/avg.js
@Author: Paul Visco
@Version: 1.1 11/19/07
@Return: Number The average value
@Example:var myArray = [1,3,4,5];
var average = myArray.avg();
average = 3.25
@Description: Makes a new independent copy of an array instead of a pointer to it
@File: Array/prototype/copy.js
@Author: Paul Visco
@Version: 1.1 11/19/07
@Return: Array A new array with the same value as the one it is making a copy of
@Example:var myNewArray = myArray.copy();
@Description: Cycles through an array by incrememtning its pointer and reseting it back to the beginng (0) when it gets to the end.
@File: Array/prototype/iteration.js
@Author: Paul Visco
@Version: 1.2 08/21/09
@Param: Number direction Accepts either 1 for ascending order or -1 for decending order. If not specified that ascending order is the default.
@Return: Array Returns The array sorted naturally.
@Example:var myArray = [1,10,2,3,4,5];
var answer = myArray.cycle();
alert(myArray.cycle());
@Description: empties an array
@File: Array/prototype/empty.js
@Author: Paul Visco
@Version: 1.1 11/19/07
@Return: returns the array emptied
@Example:myArray.empty();
@Description: Finds the index of the value given within the array. Return the position of the first matching value. Rememeber that array start at 0.
@File: Array/prototype/inject.js
@Author: Paul Visco
@Version: 1.1 11/19/07
@Param: Object/String/Number val The value to inject into the array.
@Return: Integer
@Example:var myArray = ['zero', 'one', 'two'];
var answer = myArray.inject(1, 'bagel');
//answer is now ['zero', 'bagel', 'one', 'two'];
@Description: Finds the maximum value in an alpha/numeric array. Sorts alphanumerically and chooses the highest. Number have preference over letters, so 1 is higher than 'apple'
@File: Array/prototype/max.js
@Author: Paul Visco
@Version: 1.1 11/19/07
@Return: String/Number Returns the max value
@Example:var myArray = [5, 10, 15];
var answer = myArray.max();
//answer = 15;
@Description: Finds the minimum value in an alpha/numeric array. Sorts alphanumerically and chooses the lowest. Numbers are higher than letters, so 'apple' is lower than 1
@File: Array/prototype/min.js
@Author: Paul Visco
@Version: 1.1 11/19/07
@Return: String/Number Returns the min value
@Example:var myArray = [5, 10, 15];
var answer = myArray.min();
//answer = 5;
@Description: Finds the most common value in an array. If no value is most common then it returns false.
@File: Array/prototype/mostCommon.js
@Author: Paul Visco
@Version: 1.1 11/19/07
@Return: String/Number/Object Returns the most common value in the array or false if no value is most common.
@Example:var myArray = [5, 10, 15];
var answer = myArray.mostCommon();
//answer = false;
var myArray = [5, 5, 10, 15];
var answer = myArray.mostCommon();
//answer = 5;
@Description: Sort the array values in a natural alpha numeric way so that 1,10,2,3,4,5 becomes 1,2,3,4,5,10
@File: Array/prototype/natsort.js
@Author: Paul Visco
@Version: 1.1 11/19/07
@Param: Number direction Accepts either 1 for ascending order or -1 for decending order. If not specified that ascending order is the default.
@Return: Array Returns The array sorted naturally.
@Example:var myArray = [1,10,2,3,4,5];
var answer = myArray.natsort();
//answer = [1,2,3,4,5,10];
@Description: Grab a random value from the array. The value is randomly selected each time the value is run.
@File: Array/prototype/random.js
@Author: Paul Visco
@Version: 1.1 11/19/07
@Return: Object/String/Number Returns a random value from the array. Type is the same as the value.
@Example:var myArray = [1,10,2,3,4,5];
var answer = myArray.random();
//answer = 4; //<--could change each time
@Description: Determines the range of values in a numeric array. That is the highest value minus the loweest value
@File: Array/prototype/range.js
@Author: Paul Visco
@Version: 1.1 11/19/07
@Return: Number The range of the values
@Example:var myArray = [1,10,2,3,4,5];
var answer = myArray.range();
//answer = 9; //<--the difference between 10 (the highest number) and 1 (the lowest number)
@Description: Limit the values of an array to Values that do not match the regex expression are excluded
@File: Array/prototype/regex.js
@Author: Paul Visco
@Version: 1.1 11/19/07
@Return: Array Returns an array of values that match the regex from the original array
@Example:var myArray = [5, 10, 15];
var answer = myArray.regex(/\d{2}/);
//answer = [10,15] //because they are at least two digits as specified in the regex \d{2}
@Description: Removes a value or a set of values from an array.
@File: Array/prototype/remove.js
@Author: Paul Visco
@Version: 1.1 11/19/07
@Param: values Array If passed an array of values, all the values in the argument array are removed from the array being manipulated
@Param: value Object/String/Number If a single object, string, number, etc is passed to the function than only that value is removed.
@Return: Array Returns the array minus the values that were specified for removal.
@Example:var myArray = [5, 10, 15];
var answer = myArray.remove([10,5]);
//answer =[15];
var myArray = [6, 7, 8];
var answer = myArray.remove(6);
//answer =[7,8];
@Description: Shuffle the values in an array randomly
@File: Array/prototype/shuffle.js
@Author: Paul Visco
@Version: 1.1 11/19/07
@Param: values Array If passed an array of values, all the values in the argument array are removed from the array being manipulated
@Param: value Object/String/Number If a single object, string, number, etc is passed to the function than only that value is removed.
@Return: Array Returns the array minus the values that were specified for removal.
@Example:var myArray = [5, 10, 15];
myArray.shuffle();
//myArray =[10, 15, 5]; //<-could change each time
@Description: Add up the values in an array
@File: Array/prototype/sum.js
@Author: Paul Visco
@Version: 1.1 11/19/07
@Return: Number Returns the sum of all the values in an array
@Example:var myArray = [5, 5, 10, 15];
var answer = myArray.sum();
//answer =35;
@Description: Removes duplicate values from an array
@File: Array/prototype/unique.js
@Author: Paul Visco
@Version: 1.1 11/19/07
@Return: Array Returns an array of unique values from the original array
@Example:var myArray = [5, 5, 10, 15];
var answer = myArray.unique();
//answer =[5,10,15];