Created
February 21, 2019 11:24
-
-
Save LRagji/e3944590e30ea6e85820184df635d05d to your computer and use it in GitHub Desktop.
[JS]Pro-Tips:Always specify "radix" in parseInt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let i=parseInt(0700,10)//GOOD Implementation radix is passed. | |
let i=parseInt(0700)//BAD Implementation choosing the radix is now upto the runtime. | |
//Check this article: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt | |
//If the input string begins with "0", radix is eight (octal) or 10 (decimal). Exactly which radix is chosen is implementation-dependent. ECMAScript 5 specifies that 10 (decimal) is used, but not all browsers support this yet. For this reason always specify a radix when using parseInt. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment