Grep vs Filter in jQuery?

前端 未结 5 447
天命终不由人
天命终不由人 2020-12-13 11:36

I was wondering about the differences between Grep and Filter :

Filter :

Reduce the set of matched elements to those that match the selector

5条回答
  •  一生所求
    2020-12-13 12:32

    They both function in similar ways however they differ in their usages.

    The filter function is intended to be used with html elements, and that is why it is a chainable function that returns a jQuery object and it accepts filters like ":even", ":odd" or ":visible" etc. You can't do that with the grep function, which is intended to be a utility function for arrays.

提交回复
热议问题