[英]How to perform filter in java script objects?
如何根據條件過濾 javascript 對象?
I tried this, but still it fills the remaining index of the object as null, I don't want the part of object if it doesn't meet my condition,here the condition is only if the index of the object is less the selectedIndex (這是我程序中的一些值)應該選擇它,其余的不是必需的
console.log(Object.keys(registrationData).map((val,ind)=>{
return (ind<=selectedIndex ) ? registrationData[val] :null
}));
嘗試這個
Object
.values(registrationData)
.filter((value, index) => index <= selectedIndex)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.