Array

Description

The Javascript Array type.

Remarks

Unless otherwise noted, all functions herein are added to Array.prototype, and thus are already a part of every Array's members.

Function List

Function Documentation

increment(amount)

Increments/decrements all numeric elements of an array by an arbitrary value.

Parameters

amount:The amount to add to all numeric elements.

Returns

The calling Array object (Array.this).

max(val)

Sets an array's numeric elements to the maximum of themselves and an arbitrary value.

Parameters

val:The value to check each numeric element against.

Returns

The calling Array object (Array.this).

mean()

Determines the mean value of an array's numeric elements.

Returns

The mean value.

Remarks

Elements for which isNaN() == true are skipped, so a return value of 0.0 may simply mean your array had no numeric elements.

median()

Determines the median value of an array's elements.

Returns

The median value.

Remarks

Since median is a position-based check, the returned element may or may not be a numeric value. Using this on arrays that don't contain only numeric data will likely produce nonsensical results.

min(val)

Sets an array's numeric elements to the miniumm of themselves and an arbitrary value.

Parameters

val:The value to check each numeric element against.

Returns

The calling Array object (Array.this).

shuffle()

Randomizes the order of elements within an array.

Returns

The calling Array object (Array.this).

Remarks

More information: Stack Overflow: How to randomize (shuffle) a javascript array?