js的几种转换数组为字符串的代码
var colors=["red","blue","green"]
alert(colors.join(","))
alert(colors.join("||"));
alert(colors.toString());
alert(colors.valueOf());
alert(colors);
堆栈
var colors=["red","blue","green"]
var count=colors.push('red','green');
alert(count)
count=colors.push('black');
alert(colors[5]);
alert(colors.length)
var item=colors.pop();
alert(item);
alert(colors.length)
队列
var colors=["red","blue","green"]
var count=colors.push('red','green');
alert(count)
count=colors.push('black');
alert(colors[5]);
alert(colors.length)
var item=colors.shift();
alert(item);
alert(colors.length)
var values=[1,2,33,4,5,6];
alert(values.reverse()) //按顺序从大到小
values.sort(); // 按顺序从小到大 。。只管顺序不管内容
alert(values);