js-数组面试题



 <!DOCTYPE html>
 <html>
 <head>
 <meta charset="utf-8" />
 <title></title>
 </head>
 <body>
 <script>
 //完成以下代码段,实现b数组对a数组的拷贝,方法越多越好
 var a=[1,"yes",3],
 b;
 // 1.数组遍历,push
 // b=new Array();
 // for(var i=0;i<a.length;i++){
 // b.push(a[i])
 // }
  
 // 2.concat() 连接两个或多个数组
 // b=[].concat(a)
  
 // 3.slice()
 b=a.slice(0)
 console.log(b)
 </script>
 </body>
 </html>
 
  
 
posted on 2018-06-08 08:47  革命军总部  阅读(1064)  评论(0)    收藏  举报