Math Floor function of Javascript returns the nearest smaller value to the specified number. Math floor function means the floor value i.e. lower value for the specified value. Math.floor(x) function returns the lower nearest value for the specified number. Math.floor function truncates the decimal precision point values of the number and returns the smallest integer. If the specified number is an integer value then Javascript Math floor function returns the same value.

Syntax for Javascript Math Floor Function

Math.floor(x);

Math.floor function accepts value as number as returns nearest lower integer value for it.

Examples of Javascript Math Floor Function

document.write(Math.floor(0.51) + "<br />");

document.write(Math.floor(2) + "<br />");

document.write(Math.floor(2.1) + "<br />");

document.write(Math.floor(2.84) + "<br />");

document.write(Math.floor(-2.44) + "<br />");

document.write(Math.floor(-6.44) + "<br />");

document.write(Math.floor(-6.94) + "<br />"); 

// Output:
// 0
// 2
// 2
// 2
// -3
// -7
// -7

Continue to next tutorial: Javascript Math Pow Function to learn how to calculate the value of base according to its exponential power.

Recent JavaScript Tutorials

Javascript FSO ShortPath property

Javascript FileSystemObject (FSO) provides a ShortPath property that can be accessed using the folder object or file object returned by the GetFolder or GetFile method.

Javascript FSO Path Property

Javascript FileSystemObject (FSO) provides the Path property that can be accessed through the file object or folder object returned by the GetFile or GelFolder method

Javascript FSO Type property

Javascript FileSystemObject (FSO) provides a Type property that can be accessed through file object or folder object returned by the GetFile or GetFolder method

Javascript FSO ShortName property

Javascript FileSystemObject (FSO) provides a ShortName property that can be accessed using the folder object or file object returned by the GetFolder or GetFile method.

Javascript FSO Name Property

Javascript FileSystemObject (FSO) provides a Name property that can be accessed using file object or folder object.