==========================================================================================chrome
真:true , 非零數字 , 非空字符串 , 非空對象json
假:false , 數字零 , 空字符串 , 空對象, undefined數組
==========================================================================================
ide
Json函數
循環:spa
1.數組 for 0--length對象
2.json for in排序
==========================================================================================
字符串
CSS函數get
arguments --- 不定參
function sum(){
var result = 0;
for(var i in arguments){
result += arguments[i];
}
return result;
}
==========================================================================================
取非行間樣式
//不能取複合樣式 ----background,border
obj.currentStyle[attr] //IE
getComputedStyle(obj,false)[attr] //chrome FF
function getStyle(obj,attr){
if(obj.currentStyle){
return obj.currentStyle[attr];
}else{
return getComputedStyle(obj,false)[attr];
}
}
==========================================================================================
數組的使用
一,添加、刪除
1.頭部添加
arr.unshift();
尾部添加
arr.push();
2.頭部刪除
arr.shift();
尾部刪除
arr.pop();
3.中間添加、刪除
刪除: splice(起點,長度);
添加: splice(起點,0,元素);
替換: splice(起點,元素個數,元素); //先刪除,後添加
2、排序、轉換
1.鏈接
a.concat(b);
a.join('-');//數組內部的元素用'-'鏈接
2.排序
sort();
var arr = [123,354,57567,798,90,8,7]; arr.sort(function(i,j){ /*if(i<j){ return -1; }else if(i>j){ return 1; }else{ return 0; }*/ return i-j; }); window.onload = function(){ alert(arr); };