域名預(yù)訂/競(jìng)價(jià),好“米”不錯(cuò)過(guò)
<pre>//數(shù)組對(duì)象 const people = [ {name:'Henry',age:20}, {name:'Bucky',age:25}, {name:'Emily',age:30}, ]; // 需求,取第一個(gè)age // es5 var age = people[0].age; console.log(age)//20 // es6解構(gòu) const [age] = people; /** * 因?yàn)榈谝粚咏鈽?gòu)的是數(shù)組,所以會(huì)返回第一條的整條數(shù)據(jù) */ console.log(age)//{ name: 'Henry', age: 20 } /** * 如果想拿第一條數(shù)據(jù)的age值就得再解構(gòu)一次 */ const [{age}] = people; console.log(age)//20</pre>文章來(lái)源:田珊珊個(gè)人博客
來(lái)源地址:http://www.tianshan277.com/682.html
申請(qǐng)創(chuàng)業(yè)報(bào)道,分享創(chuàng)業(yè)好點(diǎn)子。點(diǎn)擊此處,共同探討創(chuàng)業(yè)新機(jī)遇!