1、防止崩溃的可选链(?)
在未定义的属性时使用可选链运算符,将返回undefined而不会报错。可防止代码崩溃
const student = {
name: "Matt",
age: 27,
address: {
state: "New York"
},
};
// LONG FORM
console.log(student && student.address && student.address.ZIPCode); // Doesn't exist - Returns undefined
// SHORTHAND
console.log(student?.address?.ZIPCode); // Doesn't exist - Returns undefined
2、指数运算符 (**)
Math.pow(2,4) === 2**4
3.四舍五入的Math.floor()简写
Math.floor(5.23) === ~~5.23 === 5



