注意:**1.左边读取的字段,右手边必须有
    2.读取的是右边的一个层级**

    1. var obj = {
    2. name:"lisi",age:18,skill:"vue",
    3. s:{
    4. sex:"male"
    5. }
    6. }
    7. /*
    8. var name = obj.name
    9. var age = obj.age
    10. var skill = obj.skill
    11. */
    12. var {name,s} = obj
    13. console.log(name);
    14. console.log(s.sex);

    例子

    1. var obj = [
    2. {name:"zheng",age:18,skill:"vue"},
    3. {name:"zhang",age:17,skill:"js"},
    4. {name:"liu",age:20,skill:"html"}
    5. ]
    6. /* arr = [{name:"xx",skill:"xxx"},{name:"xx",skill:"xxx"}] */
    7. var arr = []
    8. for(var i=0;i<obj.length;i++){
    9. /* var name = obj[i].name;
    10. var skill = obj[i].skill; */
    11. var {name,skill} = obj[i]
    12. arr.push({
    13. /* name:name,skill:skill */
    14. name,
    15. skill
    16. })
    17. }
    18. console.log(arr);