Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - Excuse me, how to convert a var into int in javascript, such as var i=2.5, and how to convert I into 2, thank you.
Excuse me, how to convert a var into int in javascript, such as var i=2.5, and how to convert I into 2, thank you.
var I = parse int(" 2.5 ");

ParseInt syntax: parseInt (string, radix);

Where string is the string to be converted and radix is binary, octal, hexadecimal or decimal.

When radix is not specified by default, it is hexadecimal when switching with 0x; If it starts with 0 and the second digit is not X, it is considered octal (because octal cannot have 8 or 9, it will return 0 when an error occurs).

I believe you understand this explanation, right?