ES6 - Fonction mathématique trunc ()

Il renvoie la partie intégrale de x (tous les chiffres fractionnaires sont supprimés).

Syntaxe

Math.trunc( x ) ;

Paramètre

  • X - représente un nombre

Exemple

console.log("---Math.trunc()---") 
console.log("Math.trunc(7.7) : "+Math.trunc(7.7)) 
console.log("Math.trunc(-5.8) : "+Math.trunc(-5.8))

Production

---Math.trunc()--- 
Math.trunc(7.7) : 7 
Math.trunc(-5.8) : -5