数组在javascrip中的使用
>var arr = new Array();
undefined
>arr[0] = "梅西";
"梅西"
>arr[1] = "c罗";
"c罗"
>arr[2] = "内马尔";
"内马尔"
>arr.push("伊斯科");
4
>arr.length
4
>arr.pop
function pop() { [native code] }
>arr.pop();
"伊斯科"
>arr.length
3
>arr.pop();
"内马尔"
>arr.length
2
>arr.push
function push() { [native code] }
>arr.length
2
>arr[0]
"梅西"
>arr[1]
"c罗"
>arr.push("伊斯科","内马尔")
4
>arr.length
4
>arr.unshift("克洛泽")
5
>arr.length
5
>arr[4]
"内马尔"
>arr[0]
"克洛泽"
>arr.shift
function shift() { [native code] }
>arr.shift();
"克洛泽"
>arr.length
4
>arr.join(",")
"梅西,c罗,伊斯科,内马尔"
>arr
["梅西", "c罗", "伊斯科", "内马尔"]
>arr.pop
function pop() { [native code] }
>arr.pop();
"内马尔"
>arr
["梅西", "c罗", "伊斯科"]
>arr.shift
function shift() { [native code] }
>arr.shift()
"梅西"
>arr
["c罗", "伊斯科"]
>arr.shift
function shift() { [native code] }
>arr
["c罗", "伊斯科"]
>arr.join(",")
"c罗,伊斯科"
>arr.sort()
["c罗", "伊斯科"]
>arr.unshift("梅西")
3
>arr
["梅西", "c罗", "伊斯科"]
>arr.sort();
["c罗", "伊斯科", "梅西"]
>arr.reverse()
["梅西", "伊斯科", "c罗"]
>arr.reverse()
["c罗", "伊斯科", "梅西"]
>arr.reverse()
["梅西", "伊斯科", "c罗"]
>arr.reverse()
["c罗", "伊斯科", "梅西"]
>arr.splice
function splice() { [native code] }
>arr.splice()
[]
>arr
["梅西", "伊斯科", "c罗"]
>var arrs = ["克洛泽"];
undefined
>arr
["梅西", "伊斯科", "c罗"]
>arrs
["克洛泽"]
>arr.concat
function concat() { [native code] }
>arr.concat(arrs);
["梅西", "伊斯科", "c罗", "克洛泽"]
>arr
["梅西", "伊斯科", "c罗"]
>arrs
["克洛泽"]
>arrs.concat(arr)
["克洛泽", "梅西", "伊斯科", "c罗"]
>typeof arrs
"object"
>typeof arr
"object"
>arr.valueOf
function valueOf() { [native code] }
>arr.valueOf();
["梅西", "伊斯科", "c罗"]
>arr.toString
function toString() { [native code] }
>arr.toString();
"梅西,伊斯科,c罗"
>arr.isPrototypeOf
function isPrototypeOf() { [native code] }
>arr.isPrototypeOf()
false
>arr
["梅西", "伊斯科", "c罗"]
>arr.indexOf("c罗");
2
>arr.constructor
function Array() { [native code] }
>arr.constructor()
[]
?