js 数组操作和数字字符串操作相关累积
判断是否是数组可以用 Array.isArray 来判断,示例:
var arr = [1,2];
if(Array.isArray(arr)) { console.log("是数组"); }else{ console.log("不是数组"); } 数组删除元素 var arr = ['dog','pig']; arr.splice(index,1); 两个数组去重
delArr(arr1,arr2){ var newArr = []; console.log(arr1,arr2); for(var i in arr1){ console.log(arr2.indexOf(parseInt(arr1[i])),arr2.indexOf(arr1[i])); if (arr2.indexOf(parseInt(arr1[i])) < 0 && arr2.indexOf(arr1[i]) < 0) { newArr.push(arr1[i]); } } console.log("newArr",newArr); return newArr; } 对象删除元素 var arr = { a:'dog',b:'pig' };
delete checkeddata['a'];