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,);