10.展开运算符

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      // [...]展开运算符能将数组转换为逗号分割的参数序列
      // 声明一个数组
      let arr = ["张三", "李四", "王五"];
      function fn() {
        console.log(arguments);
      }

      fn(...arr); //等同于fn('张三','李四','王五')
    </script>
  </body>
</html>
posted @ 2022-01-02 16:05  问某完红  阅读(23)  评论(0编辑  收藏  举报