We can use the
Number() method to convert a non-number value to a number.
String to Number
A String which contains a valid number as its value will be converted to a Number.
Empty strings are converted to 0.
Non-empty Strings which don’t contain a valid number are converted to
Boolean to Number
true is converted to 1, while
false is converted to 0.
Other data types to Number
null is converted to 0, while
undefined is converted to