0
Definition of parseInt
Can someone tell me an easy explanetion of parseInt in JavaScript? Thanks
1 Odpowiedź
+ 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