js中的Array()

來源:互聯網
上載者:User

標籤:java   scrip   array   

//數組的聲明方式var arr=[0,1,2,3,4,5];var arr1= new Array(); arr1[0]=‘6‘;     arr1[1]=‘7‘;     arr1[2]=‘8‘;     arr1[3]=‘9‘;     arr1[4]=‘10‘;    var arr2=new Array(11,12,13);var arr3=new Array(1);  arr3[0]=‘14‘;    //數組連結concat();  document.write(arr.concat(arr1,arr2)+‘<br>‘);    //把一個數組放到字串中  join toString();  document.write(arr.join()+‘<br>‘);  document.write(arr.join(‘---\>‘)+‘<br>‘);  document.write(arr.toString()+‘<br>‘);    //顛倒數組reverse();  document.write(arr.reverse()+‘<br>‘);    //入棧  arr.push(‘+6+‘);  document.write(arr+‘<br>‘);    //出棧  arr.pop();  document.write(arr+‘<br>‘);    //隊列  unshift()  shift()  arr.unshift(‘+6+‘);  document.write(arr+‘<br>‘);  arr.shift();  document.write(arr+‘<br>‘);     //擷取數組選定的元素slice();   document.write(arr.slice(1)+‘<br>‘);   document.write(arr.slice(1,5)+‘<br>‘);       //刪除數組添加新元素 splice() arr.splice(1,0,"test")  //添加     document.write(arr+"<br>"); arr.splice(1,1)//刪除     document.write(arr); arr.splice(1,1,"test"+"<br>");//替換  document.write(arr+"<br>");


本文出自 “web” 部落格,請務必保留此出處http://web66.blog.51cto.com/10442650/1854867

js中的Array()

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.