Programmation JavaScript/Références/Objets/Number
Apparence
Propriétés
[modifier | modifier le wikicode]- MAX_VALUE
- plus grand nombre pouvant être sauvegardé
- MIN_VALUE
- plus petit nombre pouvant être sauvegardé
- NaN
- nombre non valable
- NEGATIVE_INFINITY
- nombre trop petit
- POSITIVE_INFINITY
- nombre trop grand
Méthodes
[modifier | modifier le wikicode]- toExponential()
- toFixed()
- toPrecision()
- toString()
Exemples
[modifier | modifier le wikicode]Pour afficher arrondit un nombre formaté à la française :
let myAmountOfMoneyWithVat = document.querySelector('#myAmountOfMoneyWithVat').value.replace(/,/g, '.').replace(/ /g, '').replace(/[\s€]/g, ''); document.querySelector('#myAmountOfMoneyWithVat').value = myAmountOfMoneyWithVat.toFixed(2);