With 语句
with 语句是不推荐使用的,并且在 ES5 的严格模式下是禁用的。
with 扩展了语句的作用域,with 会把传入参数上的所有属性都附加到作用域链上。...callee 和 caller 是被禁止的。...移出数组中的重复项
const arr = [1, 1, 1, 1, 2, 3, 4, 5, 6, 7, 6, 6, 6, 7, 8, 9];
const arrWithoutDuplicates =...[...new Set(arr)];
console.log(arrWithoutDuplicates); // [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ]
Set 中的值都是唯一的,当数组经过...可选链
无论何时你需要获取嵌套对象上的属性且你不知道它是否存在,你需要向下面这样做:
const nestedObject = {
name: "Parwinder",
details: