es8(字符串,对象)

es8(字符串,对象)

字符串补白:

let str = "abc";
    let a = str.padEnd(5);
    let b = str.padStart(5);
    let c = str.padEnd(5,"a");
    let d = str.padStart(5,"a");
    console.log("|"+str+"|");//打印出|abc|
    console.log("|"+a+"|");//打印出|abc  |
    console.log("|"+b+"|");//打印出|  abc|
    console.log("|"+c+"|");//打印出|abcaa|
    console.log("|"+d+"|");//打印出|aaabc|

对象:

let obj = {
        name:"大胖",
        age:23
    };
    let arr = ["a","b"];
    console.log(Object.values(obj));//打印出["大胖", 23]
    console.log(Object.values(arr));//打印出["a", "b"]
    console.log(Object.entries(obj));//打印出[Array(2), Array(2)]

函数对象的定义调用时参数能够到场尾逗号:

function fn(a,b){
        console.log(123);

        }
    fn(1,2,);
    原文作者:songze
    原文地址: https://segmentfault.com/a/1190000010309659
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞