<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<script type="text/javascript">
var res = num.toString();
alert(num + ", " + typeof (num));
alert(res + ", " + typeof (res));
alert(num + ", " + typeof (num));
alert(res + ", " + typeof (res));
var s5 = n.toExponential(2); // 指数表示
var s6 = n.toPrecision(2); // 有效位数
alert(s4 + ", " + typeof(s4));
alert(s5 + ", " + typeof(s5));
alert(s6 + ", " + typeof(s6));
alert(s + ", " + typeof s);
alert(r + ", " + typeof r);
// parseInt() parseFloat()
alert(s + ", " + typeof s);
alert(r + ", " + typeof r);
// parse系方法,只识别一个字符串中开始的数字,如果识别不了就返回NaN
alert(parseInt("a123abc") + 1);
|