成人国产在线小视频_日韩寡妇人妻调教在线播放_色成人www永久在线观看_2018国产精品久久_亚洲欧美高清在线30p_亚洲少妇综合一区_黄色在线播放国产_亚洲另类技巧小说校园_国产主播xx日韩_a级毛片在线免费

資訊專欄INFORMATION COLUMN

es5_JSON

paulquei / 2518人閱讀

摘要:大胖騷胖大胖騷胖用來將字符串轉成對象的反序列化打印出用來將對象轉成字符串的序列化打印出大胖騷胖打印出打印出正則打印出打印出打印出打印出打印出打印出打印出打印出

es5_JSON

let str = "[{"name":"大胖","age":23},{"name":"騷胖","age":24}]";
        let arr = [
            {"name":"大胖","age":23},
            {"name":"騷胖","age":24}
            ];

用來將json字符串轉成json對象(json的反序列化):

let jsonObj = JSON.parse(str);
       console.log(jsonObj);//打印出[Object, Object] 

用來將json對象轉成json字符串(json的序列化):

let jsonStr = JSON.stringify(arr);
    console.log(jsonStr);//打印出[{"name":"大胖","age":23},{"name":"騷胖","age":24}]

String trim:

 let str5 = "       abc";
    console.log("|"+str5+"|");//打印出|       abc|
    console.log("|"+str5.trim()+"|");//打印出|abc|

正則:

 let reg = /^(s+)|(s+)$/g;
    console.log("|"+str5.replace(reg,"")+"|");//打印出|abc|

Date:

console.log(Date.now());//打印出1500706861909
console.log(new Date().toJSON());//打印出2017-07-22T07:01:01.909Z
console.log(new Date().toISOString().slice(0,10));//打印出2017-07-22

Number:

let a = new Number(1.326);
    let b = new Number(1.324);
    console.log(a.toFixed(2));//打印出1.33
    console.log(b.toFixed(2));//打印出1.32
    let c = 10000000000000;
    console.log(c.toPrecision(4));//打印出1.000e+13
    console.log(Math.round(12.34));//打印出12

function call apply:

var x = 1;
    let obj5 = {
        x:2
    }
    function fn1(a,b){
        console.log(this.x);
    }
    fn1();
    let fn2 = fn1.bind(obj5);
    fn2();

文章版權歸作者所有,未經允許請勿轉載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。

轉載請注明本文地址:http://systransis.cn/yun/84237.html

相關文章

發(fā)表評論

0條評論

paulquei

|高級講師

TA的文章

閱讀更多
最新活動
閱讀需要支付1元查看
<