搜索JavaScript方法以排除元素
我找到了这个“startsWith”方法来选择和过滤“键”,然后用JavaScript处理数据集,但现在我寻找一个与之相反的方法搜索JavaScript方法以排除元素,javascript,Javascript,我找到了这个“startsWith”方法来选择和过滤“键”,然后用JavaScript处理数据集,但现在我寻找一个与之相反的方法 str.startsWith(searchString[, position]) 例如,我只想显示没有以“article”开头的键的数据集 const data = Object.entries(y).filter(([key, value]) => (key.startsWith(!"article"))).map(([key, valu
str.startsWith(searchString[, position])
例如,我只想显示没有以“article”开头的键的数据集
const data = Object.entries(y).filter(([key, value]) => (key.startsWith(!"article"))).map(([key, value]) => {}
这里的“!”标志不起作用。JavaScript提供了更好的方法吗
谢谢这没有意义:
!"article"
您不希望对字符串的值求反,而是希望对.startsWith()
返回的值求反。从语义上讲,您希望“notstartedwith”(“notstartedwith”):
这没有道理:
!"article"
您不希望对字符串的值求反,而是希望对.startsWith()
返回的值求反。从语义上讲,您希望“notstartedwith”(“notstartedwith”):
!key.startsWith(“article”)
key.startsWith(!“article”)
与执行key.startsWith(“false”)
相同
是一个逻辑运算符,它计算您的值并返回一个布尔值
!key.startsWith(“article”)
key.startsWith(!“article”)
与执行key.startsWith(“false”)
相同
是一个逻辑运算符,用于计算值并返回一个布尔值