数组去重
var aRr=[1,3,4,1,6,9,1,2,5,3,1,6,5,4,4];
var aRr2=[];
for(var i=0;i<aRr.length;i++){
if (aRr.indexof(aRr[1])==1{
aRr2.push(aRr[i]);
}
}
alert(aRr2);
字符串处理
var str="2018-12-03";
var arr=str.split('-');//2018,12,03
alert(arr);
var arr = str.split('')//"2","0","1","8","-","1","2","-","0","3"
console.log(arr);
touppercase()转大写
tolowercase()转小写
字符串反转
var str = "12sdadsad5646sadsadas";
//spilt()字符串转为数组
//reverse()数组反转
//join()数组转成字符串
var str1 = str.split('').reverse().join('')
alert(str1)
先用spilt方法将字符串转成数组,然后在用数组反转,最后用join将数组转成字符串。
网友评论