Javascript Math floor()

Introduction

The Math.floor() function returns the largest integer less than or equal to a given number.

Math.floor(x) // x is a number.

Math.floor(null) returns 0, not a NaN.

let a = Math.floor( 5.95); 
console.log(a);/*from   ww w.java 2s.  c  o  m*/
a = Math.floor(5.05); 
console.log(a);
a = Math.floor(4); 
console.log(a);
a = Math.floor(-5.05); 
console.log(a);
a = Math.floor(-5.95); 
console.log(a);
console.log(Math.floor(25.9)); // 25 
console.log(Math.floor(25.5)); // 25 
console.log(Math.floor(25.1)); // 25 



PreviousNext

Related