JavaScript 中 类型转换

    // 转换成字符型
    var married = false;
 
    alert(married.toString());
    // 字符型转换成其他
    var test = parseInt(“blue”); //returns NaN
 
    var test = parseInt(“1234blue”); //returns 1234
 
    var test = parseInt(“22.5”); //returns 22
 
    var test = parseFloat(“1234blue”); //returns 1234
 
    var test = parseFloat(“22.5”); //returns 22.5
posted @ 2017-11-12 11:45  陈富林  阅读(138)  评论(0编辑  收藏  举报