parseInt字符串解析,常用去 单位 和 空格

parseInt方法接收两个参数,parseInt(string,radix?);

string:要被解析的值。如果参数不是一个字符串,则将其转换为字符串(toString)。字符串开头的空白符将会被忽略。
radix:可选。从 2 到 36,表示被解析的值的进制。例如说指定 10 就等于指定十进位。

var x = parseInt("10px")
console.log(x)	//  x = 10

原文链接:https://blog.csdn.net/josavion/article/details/78840700

Guess you like

Origin blog.csdn.net/qq_48729513/article/details/120467182