<script> // 对象解构,通过属性名进行解构,等号后面设置默认值 const obj = { name: ‘zs’, age: 18 } // const { name } = obj // console.log(name) zs

    newName防止与tom的name冲突

    // const name = “tom” // const { name: newName = “jack” } = obj // console.log(name) tom // console.log(newName) zs const { log } = console log(“haha”) 通过log直接输出 </script>

    对象的解构 - 图1