ES6扩展运算符的使用
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> <div></div> <div></div> <div></div> </head> <body> <script type="text/javascript"> console.log(...[1, 2, 3]) // 1 2 3 console.log(1, ...[2, 3, 4], 5) // 1 2 3 4 5 console.log([...document.querySelectorAll('div')]) //三个div var args = [1,2,3,4] console.log(...args) //1 2 3 4 var arr = [{name:'bob',sex:'男'},{name:'boob',sex:'男'},{name:'obob',sex:'男'}] console.log(...arr) //出来的是单个obj </script> </body> </html>