1 <!DOCTYPE html> 2 <html> 3 <head lang="en"> 4 <meta charset="UTF-8"> 5 <title></title> 6 </head> 7 <body> 8 <script> 9 10 var arr = ["关羽","张飞","刘备"]; 11 var arr2 = [1,2,3] 12 console.log(arr); 13 // //在数组的最末尾添加元素(返回新数组的长度) 14 // var aaa = arr.push("abc"); 15 //// var aaa = arr.push("abc","def"); 16 //// var aaa = arr.push(arr2); 17 // console.log(aaa); 18 // console.log(arr); 19 // 20 // //在数组的最末尾删除一个元素(返回新被删除的元素) 21 // aaa = arr.pop(); 22 // console.log(aaa); 23 // console.log(arr); 24 25 26 //unshift在数组的最前面添加元素 27 aaa = arr.unshift("abc"); 28 console.log(aaa); 29 console.log(arr); 30 31 aaa = arr.shift(); 32 console.log(aaa); 33 console.log(arr); 34 35 </script> 36 </body> 37 </html>
原文地址:https://www.cnblogs.com/BingBing-Deng/p/10277995.html
时间: 2024-10-03 04:01:38