let obj={ 'a':'a', 'b':null, 'c':'c' } var removePropertyOfNull=function(obj){ Object.keys(obj).forEach(item=>{ if(!obj[item]) delete obj[item] }) return obj; } removePropertyOfNull(obj) //obj={'a':'a','b':'b'}
js 删除对象中所有值为null的属性
猜你喜欢
转载自www.cnblogs.com/xingguozhiming/p/10463283.html
今日推荐
周排行