有什么方法可以在JS中使用 bool(boolean) 代数吗?

例如,我想遍历包含true&false的数组,并将其简化为true或false。

用 bool(boolean) 代数完成它似乎是一种优雅的方法。

[true,true,true,true] //would like to do a comparison that lets me
//simply add the previous value to  the current iteration of a loop
// and have this return true

[false,true,true,true]//this on the other hand should return false

最佳答案

我认为一个简单的解决方案是

return array.indexOf(false) == -1

07-24 09:38
查看更多