floor()  Math  class method JS Home  <<  JS Reference  <<  Math  <<  floor()

Description

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

  • Like all class methods floor() should be used on the class rather than an instance of the class.

Syntax

Signature Description
Math.floor(value)Returns the largest integer less than or equal to a number.

Parameters

Parameter Description
valueThe value you wish to find the floor() of:
  • Non-numeric strings returns NaN.
  • Passing no parameter returns NaN.
  • Passing null returns 0.

Examples

The code below displays floor() usage.


// Store results in an array.
var floorValues = new Array(6);

floorValues[0] = Math.floor(1.9);
floorValues[1] = Math.floor(-10.8);
floorValues[2] = Math.floor('100.1');
floorValues[3] = Math.floor('five');
floorValues[4] = Math.floor();
floorValues[5] = Math.floor(null);

alert(floorValues);  

Press the button below to action the above code:

Related Tutorials

JavaScript Advanced Tutorials - Lesson 4 - Math

JavaScript Basics

JavaScript Basics

JavaScript Intermediate

JavaScript Intermediate

JavaScript Advanced

JavaScript Advanced

JavaScript Reference

JavaScript Entities

Globals

Math

Class Properties
E
LN2
LN10
LOG2E
LOG10E
PI
SQRT1_2
SQRT2
Instance Properties
None.
Class Methods
abs()
acos()
asin()
atan()
atan2()
ceil()
cos()
exp()
floor()
log()
max()
min()
pow()
random()
round()
sin()
sqrt()
tan()
Instance Methods Getters
None.
Instance Methods Setters
None.

Statements

Operators