Skip to content
avoidwork edited this page Apr 24, 2012 · 1 revision

number

Number related methods

$(".class").each(function (i, idx) { if (idx.isOdd()) i.addClass("odd"); });

number.diff

Method

Returns the difference of arg

@param {Number} arg Number to compare
@return {Number} The absolute difference

Prototype

Number.prototype.diff

Example

Number(5).diff(2); // 3

number.even

Method

Tests if an number is even

@param {Number} arg Number to test @return {Boolean} True if even

Prototype

Number.prototype.isEven

Example

Number(0).isEven(); // true

number.format

Method

Formats a Number to a delimited String

@param  {Number} arg       Number to format
@param  {String} delimiter [Optional] String to delimit the Number with
@param  {String} every     [Optional] Position to insert the delimiter, default is 3
@return {String} Number represented as a comma delimited String

Prototype

Number.prototype.format

Example

Number(1024).format(); // "1,024"

number.odd

Method

Tests if an number is odd

@param {Number} arg Number to test @return {Boolean} True if odd

Prototype

Number.prototype.isOdd

Example

Number(1).isOdd(); // true