string转numberjava_number与string的转换// number -> string
// toString()
/*
var num = 10;
var res = String();
alert(typeof (num));
alert(typeof (res));
*/
// 加⼀个空格卤肉
/*
var num = 10;
var res = num + ""
alert(num + ", " + typeof (num));
银行国庆节上班吗alert(res + ", " + typeof (res));
怎么查询车牌号车主*/
// 使⽤String(数字)函数
/*
var num = 10;
以感恩为话题作文var res = String(num);
alert(num + ", " + typeof (num));
alert(res + ", " + typeof (res));
*/
/
/ 没有固定精度的表⽰
/*
var n = 1234.56789;
var s4 = n.toFixed(2);
var s5 = n.toExponential(2); // 指数表⽰
var s6 = n.toPrecision(2); // 有效位数
alert(s4 + ", " + typeof(s4));中秋法定假日几天
alert(s5 + ", " + typeof(s5));
alert(s6 + ", " + typeof(s6));
*/
使命召唤6 配置// string -> number
/
/ 做除了加法以外的数字运算
/*
var s = "12345";
var r = s / 1; // s - 0;
alert(s + ", " + typeof s);
alert(r + ", " + typeof r);
*/
// 使⽤parse系⽅法
// parseInt() parseFloat()
/*
var s = "08";
var r = parseInt(s);
alert(s + ", " + typeof s);
alert(r + ", " + typeof r);
*/
// 使⽤Number()函数
发布评论