Math
is a built-in object in JavaScript that contains different methods and properties used to perform mathematical operations. It contains the floor()
function, which is used to compute the largest integer less than or equal to a specified number.
Math.floor(param);
param
: This is the input value of the Number
type for which we want to find the floor()
.
Number
in JavaScript is a 64-bit double-precision value that is the same asdouble
in C# or Java.
Number
: This rounds the input number and returns the next largest integer smaller than or equal to the input parameter param
. It is of the Number
type.console.log("floor(-1) = " + Math.floor(-1));console.log("floor(1) = " + Math.floor(1));console.log("floor(-10.54) = " + Math.floor(-10.54));console.log("floor(10.54) = " + Math.floor(10.54));console.log("floor(11.34) = " + Math.floor(11.34));console.log("floor(-0.5) = " + Math.floor(-0.5));