Regarding the return value of array every

About the return value of array every

question:

When this.dataList is an [] array and this.setOfCheckedId size is 0, the following code will return true


 
this.checked = this.dataList.every(({ id }) => this.setOfCheckedId.has(id));
 
 

answer:

This is because the every() method is used to detect whether each element in the array meets certain conditions. If the array is empty, there are no elements to detect, so the function returns true.
In this case, dataList is an empty array, so there are no elements to detect, and the every() method returns true, indicating that every element in the array meets the specific condition.

Guess you like

Origin blog.csdn.net/weixin_44216637/article/details/129933845