What is the difference between $.map and $.grep in jQuery

前端 未结 2 983
Happy的楠姐
Happy的楠姐 2021-02-13 11:36

What is the difference between $.map and $.grep in jQuery?

I want a simple answer as far as possible.

2条回答
  •  醉话见心
    2021-02-13 11:53

    I will assume you mean $.grep and $.map. The difference is that we use $.grep to filter an array while we use $.map to apply a function to each item in the array.

    Here is a much better explanation than I can make:

    http://onwebdev.blogspot.com/2011/03/jquery-grep-and-map-example-and-syntax.html

提交回复
热议问题