尝试解构并发现相同的代码适用于stackoverflow而不是Codepen(玩具得到“未定义”):http://codepen.io/tsalexey544/pen/VjWxmm?editors=0010#
这是什么意思?我在项目中使用解构时应该担心吗?
let obj = {
species: "Cat",
// toy: "ball",
}
function whatDoTheyDo ({species, toy = "ball"}) {
return `The ${species} playes with a ${toy}`
}
document.write(whatDoTheyDo(obj));