Prototype JavaScript framework

class Number

Description

Extensions to the built-in Number object.

Prototype extends native JavaScript numbers in order to provide:

Instance methods

  • abs

    Number#abs() -> Number

    Returns the absolute value of the number.

  • ceil

    Number#ceil() -> Number

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

  • floor

    Number#floor() -> Number

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

  • round

    Number#round() -> Number

    Rounds the number to the nearest integer.

  • succ

    Number#succ() -> Number

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

  • times

    Number#times(iterator) -> Number

    Calls iterator the specified number of times. The function takes an integer as the first parameter; it will start at 0 and be incremented after each invocation.

  • toColorPart

    Number#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

    Number#toJSON() -> String

    Returns a JSON string representation of the number.

  • toPaddedString

    Number#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.