解构

作者: 空天啸鹤 | 来源:发表于2019-04-23 19:32 被阅读0次

https://blog.csdn.net/qq_25186543/article/details/79630564

var people = [
  {
    name: "Mike Smith",
    family: {
      mother: "Jane Smith",
      father: "Harry Smith",
      sister: "Samantha Smith"
    },
    age: 35
  },
  {
    name: "Tom Jones",
    family: {
      mother: "Norah Jones",
      father: "Richard Jones",
      brother: "Howard Jones"
    },
    age: 25
  }
];
 
for (var {name: n, family: { father: f } } of people) {
  console.log("Name: " + n + ", Father: " + f);
}
 
// "Name: Mike Smith, Father: Harry Smith"
// "Name: Tom Jones, Father: Richard Jones"

相关文章

网友评论

      本文标题:解构

      本文链接:https://www.haomeiwen.com/subject/iqvbgqtx.html