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,);
    原文作者:骚胖
    原文地址: https://segmentfault.com/a/1190000010312945
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞