Skip to content

Number Method Reference

Rounds a number up to the smallest integer greater than or equal to itself.

var ceil = 0.5.ceil(); // 1
var ceil = -0.5.ceil(); // 0

None

Number - For numbers above zero, rounds to the next whole number. For numbers below zero, rounds up towards zero.

Rounds a number down to the largest integer less than or equal to itself.

var floor = 0.5.floor(); // 0
var floor = -0.5.floor(); // -1

None

Number - For numbers above zero, rounds down to the nearest whole number. For numbers below zero, rounds down away from zero.

Returns the smallest of the two numbers.

var min = 10.min(1); // 1

other: Number - The other number to compare to.

Number - The smallest of the two numbers.

Returns the largest of the two numbers.

var max = 10.max(1); // 10

other: Number - The other number to compare to.

Number - The largest of the two numbers.

Returns only the integer part of a number.

var floor = 0.5.trunc(); // 0
var floor = -0.5.trunc(); // 0

None

Number - The integer part of the number, discarding the rest.