Discuss / JavaScript / JS居然没有判断字符串是否在array的方法

JS居然没有判断字符串是否在array的方法

Topic source

alienation

#1 Created at ... [Delete] [Delete and Lock User]

总是在莫名奇妙的地方拉胯

var father =  document.getElementById('test-list')
var s =  Array.from(father.children).filter(x=> x.innerText ==='Swift' || x.innerText ==='ANSI C' ||x.innerText ==='DirectX' ).map(x=>{father.removeChild(x)})

alienation

#2 Created at ... [Delete] [Delete and Lock User]

翻了评论区原来是有的array.includes.改写

var father =  document.getElementById('test-list')
L = ['Swift','ANSI C','DirectX']
var s =  Array.from(father.children).filter(x=> L.includes(x.innerText)).map(x=>{father.removeChild(x)})

  • 1

Reply