如何在过滤器之前使用 toLowerCase() 函数?

How to use toLowerCase() function before filter?

我想在过滤前将 product.productName 小写,但我做不到。我尝试了一些东西但没有用。有什么办法可以在过滤器之前将 product.productName 小写吗?

.map() 可以用作 filter()

之前的步骤
products
  .map(product => product.productName.toLowerCase())
  .filter(...)

比较之前在过滤器内部简单地转换为小写。
例如
product.productName.toLowerCase().includes .....

如果它抱怨是一个对象,请先转换为字符串。

product.productName.toString().toLowerCase().includes ....