1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
| <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>ES6的语法:传播操作符【...】</title> </head> <body> <script> var person1 = { name: '小飞飞', age: 16, }; var {name,age} = person1; var person2 = { ...person1, gender:1, tel:13478900 }; console.log(person2); var person3 = { name:"李四", gender:1, tel:"11111", address:'广州' }; var {name,gender,...person4} = person3; console.log(name) console.log(age) console.log(person4) function findUsers(){ $.get("xxxxx",function(res){ var res = { pages:11, pageSize:10, pageNo:1, firstFlag:true, lastFlag:false, total:123, data:[{},{},{},{}], }; var {data:users,...pagesjon} = res; /* var users = res.data; var pagesjon = { res = { pages:11, pageSize:10, pageNo:1, firstFlag:true, lastFlag:false, total:123, }; */ }) } </script> </body> </html>
|