1. // demo1.1 在对象中使用
    2. let obj1 = {
    3. name: 'zs',
    4. age: 100
    5. }
    6. let obj2 = {
    7. addr: 'gx'
    8. }
    9. let obj = {
    10. ...obj1,
    11. ...obj2
    12. }
    13. console.log(obj);
    14. // demo1.2 在对象中使用:koa合并get请求和post请求参数
    15. app.use((ctx,next)=> {
    16. ctx.params = {
    17. ...ctx.query,
    18. ...ctx.request.body
    19. }
    20. next();
    21. })
    22. // demo2 在数组中使用:合并数组
    23. let arr1 = [1, 2, 3];
    24. let arr2 = [4, 5, 6];
    25. let arr = [
    26. ...arr1,
    27. ...arr2
    28. ]
    29. console.log(arr);
    30. // demo3 在函数中使用
    31. function test(a, b, ...c) {
    32. console.log(a);
    33. console.log(b);
    34. console.log(c);
    35. }
    36. test(1, 2, 3, 4, 5, 6);