All objects in JS have toString methods, which implicitly convert a variable to a string. The toString() methods of objects of type Number are special, with default mode and base mode.

(1) By default, no matter what notation is used to declare a numeric variable, it will be returned in decimal

(2) In base mode, it will be converted to the corresponding base

2. The parseInt () method

parseInt(demo ,radix); // Demo is the number you want to convert, the radix is based on what base, if this parameter is omitted or its value is 0 then the number will be parsed on the basis of 10. If the parameter is less than 2 or greater than 36 then parseInt() will return NaN

ParseInt (10,2)// The result is 2 since 10 is binary convert it to base 2