Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
What is the difference between jQuery.map() and jQuery.grep() Functions in jQuery?
The jQuery map function translates a set of elements in the jQuery object into another set of values in a jQuery array which may, or may not contain elements. The grep() function is used to find an element of an array. The difference is we use $.grep to filter an array and $.map to apply a function to each item in the array.
jQuery map function
The map method translates a set of elements in the jQuery object into another set of values in a jQuery array which may, or may not contain elements.
The following are the parameters of jQuery.map() method:
- callback ? The function to execute on each element in the set.
Example
You can try to run the following code to learn how to work with jQuery.map() method:
jQuery Map Method
- First
- Second
- Third
- Fourth
- Fifth
jQuery grep function
The grep() function is used to find an element of an array.
Example
You can try to run the following code to learn how to work with grep():
jQuery grep() function
