parseInt function in javascript

parseInt function in JavaScript

 
It is used to parse the string and return the integer.
 
Here we take some examples of parseInt()
 
If there is a string like "The Digit is 50" the answer in the parseInt() is 50
  1. document.write(parseInt(" The Digit is 50 ")); 
If there is a floating-point number:
  1. document.write(parseInt(" 5.22 ")); 
Answer: 5
 
If the string begins with "0x", the answer will be 16
  1. document.write(parseInt("0x10")); 
If the string begins with "0", the answer will be 8
  1. document.write(parseInt("010")); 
and if it is:
  1. document.write(parseInt("013")); 
The answer will be 11
Next Recommended Reading Function Overloading In JavaScript