之前在做多條件篩選時(shí)用到了對(duì)象雨让,多條件篩選的思路疮胖,并總結(jié)了幾個(gè)關(guān)于對(duì)象的操作
var array = new Object()
創(chuàng)建一個(gè)空對(duì)象用來存儲(chǔ)你傳的參數(shù)这吻,就是每個(gè)點(diǎn)擊事件都要傳參且也要將參數(shù)存儲(chǔ)起來
同時(shí)篩選里面也會(huì)涉及到清空參數(shù)以及刪除某一個(gè)值筛婉,例子:
var array={"name": "xiaojiayu", "age": 24, "gender": "man","sex":""};
?1户侥、刪除對(duì)象里某一個(gè)值
delete array.name ? ? ? ? ? ?
2却邓、清空對(duì)象
for(var key in array){
????delete array[key] ? ? ? ? ?
}
?3硕糊、清除對(duì)象里空的鍵值對(duì)
for(var key in array){
????if(array[key] === ""){
????????delete array[key] ? ? ? ? ?
????}
}