猿问
数组怎么返回符合条件的元素
比如
["1","","","",""]
我想得到数组里不为""的元素,即返回结果为"1"
慕后森
浏览 1422
回答 4
4回答
婷婷同学_
var items = ["1","","","",""]var filtered_items = items.filter(item => item !== '')console.log(filtered_items)
0
0
0
aluckdog
["1","","","",""].filter(v=>v!="")
0
0
0
一只甜甜圈
filter了解一下。
0
0
0
随时随地看视频
慕课网APP
相关分类
JavaScript
我要回答