First, I will share with you one article
Instances of int and string data types in js
https:///article/
When working on a project today, I encountered a problem that I needed to convert a variable of type String into an int type. As usual, I wrote var i = ("112"); but the console reported an error saying "'Integer' is not defined". Later, I learned that the String to int in js is different from Java, and I cannot directly use Java in js. Change to var j = parseInt("11"); it's OK.
Note: Whether it is Java or JavaScript, the parseInt method has two parameters. The first parameter is the object to be converted, and the second parameter is the cardinality, which can be 2, 8, 10, 16, and is processed in decimal by default. However, in JavaScript, numbers starting from 0 are considered to be processed in octal, and numbers of 0x are considered to be processed in hexadecimal.