测试javascript array

//test sort, slice, indexOf, valueOf

var symbols = ["USD/JPY", "CAD/JPY", "USD/EUR", "USD/CNY"];

symbols.push("AUD/JPY");

console.log(symbols);

symbols.splice(3, 1, "AAA/BBB", "CCC/DDD", "BBB/DDD");

console.log(symbols);

alert(symbols.indexOf("USD/EUR"))

symbols.sort(function(a, b){return a > b});

console.log(symbols);

alert(symbols.indexOf("USD/EUR"))

alert(symbols.valueOf());

//test only, avoid such usage for iterate array because of performance issue

for(var el in symbols)

{

if(symbols.hasOwnProperty(el))

{

console.log(el + "\t" + symbols[el] +"\t");//key value pair, key is 0,1,2,3...

}

}


你可能感兴趣的:(测试javascript array)