0

Definition of parseInt

Can someone tell me an easy explanetion of parseInt in JavaScript? Thanks

1st Apr 2020, 5:43 PM
carloalberto lupo
carloalberto lupo - avatar
1 Respuesta
+ 1
parseInt is a function that takes a string and tries to convert that string to a number. Example: a = parseInt("4.25"); /* This converts the string "4.25" to a number 4.25 and it is stored in 'a' */ a = parseInt("abc"); /* You cannot convert the string "abc" to number, 'a' will be NaN (this means "It is Not a Number") */ Useful links: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt https://www.w3schools.com/jsref/jsref_parseint.asp
1st Apr 2020, 5:54 PM
Raúl