Number

Prototype extends native JavaScript numbers in order to provide:

What becomes possible


$R(1, 10).each(function(index) {
  // This gets invoked with index from 1 to 10, inclusive
});

(5).times(function(n) {
  // This gets invoked with index from 0 to 5, *exclusive*
  // The parentheses are due to JS syntax, if we did not use a literal, they'd be superfluous
});

(128).toColorPart()
// -> '80'

(10).toColorPart()
// -> '0a'

'#' + [128, 10, 16].invoke('toColorPart').join('')
// -> '#800a10'

Методы

abs

abs() -> Number

Returns the absolute value of the number.

ceil

ceil() -> Number

Returns the smallest integer greater than or equal to the number.

floor

floor() -> Number

Returns the largest integer less than or equal to the number.

round

round() -> Number

Rounds the number to the nearest integer.

succ

succ() -> Number

Returns the successor of the current Number, as defined by current + 1. Used to make numbers compatible with ObjectRange.

times

times(iterator) -> Number

Encapsulates a regular [0..n[ loop, Ruby-style.

toColorPart

toColorPart() -> String

Produces a 2-digit hexadecimal representation of the number (which is therefore assumed to be in the [0..255] range). Useful for composing CSS color strings.

toJSON

toJSON() -> String

Returns a JSON string.

toPaddedString

toPaddedString(length[, radix]) -> String

Converts the number into a string padded with 0s so that the string’s length is at least equal to length. Takes an optional radix argument which specifies the base to use for conversion.

pvp сервер requiem online . Фітотерапія, це не просто наука про рослини.