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|

對象:code

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,);
相關文章
相關標籤/搜索