陣列方法的應用
預設的兩個陣列內容
var myarray1 = [ "one", "two", "three" ];
var myarray2 = [ "four", "five", "six" ];
- res = myarray1.join('| ') 輸出的結果: res: "one| two| three"
- myarray3 = myarray1.concat(myarray2) 輸出的結果: myarray3: "one,two,three,four,five,six"
- res = myarray1.pop() 輸出的結果: myarray1: "one,two"
- res = myarray1.push("seven") 輸出的結果: myarray1: "one,two,seven"
- res = myarray1.shift() 輸出的結果: myarray1: "two,seven"
- myarray4 = myarray3.slice(1,4) 輸出的結果: myarray4: "one,two,three,four,five,six"
- myarray3.sort() 輸出的結果: myarray3: ""
- myarray3.reverse() 輸出的結果: myarray3: ""
- res = myarray4.toString() 輸出的結果: res: ""