Search within TutorialsPark

Jquery Arrays: Creation and Manipulation


Learn to use jQuery Functions to Create and Manipulate Arrays


jQuery Arrays : Creating Arrays

The jQuery function $.makeArray() is used to convert an object into a array.

Example: Creating an Array using jQuery

Give it a TRY! » Note: It accepts an array-like object to be converted


jQuery Arrays : Searching an Array

Jquery function $.inarray() is used to search an array for particular elements, it return where in the array the value you are searching for is located(i.e index)

In the Demo below, searchTerm is the term being searched and array is the array being searched

Syntax: Searching an Array

Example: Searching an Array

Give it a TRY! » Note:If no match is found, it returns -1, like other utility methods


jQuery Array: Filtering an Array

The jQuery $.grep(array, function, invert) method is used to filter the contents of an array based on a function

Example: jQuery Array Filtering an Array

Give it a TRY! » Note:It returns a newly constructed, filtered array.


jQuery Arrays: Eliminate Duplicate Elements from Arrays

The jQuery function $.unique() is used to create a copy of an array of object with the duplicate elements removed.

Example: Eliminate Duplicate Method

Give it a TRY! » Note:It returns an array consisting of only unique objects.


jQuery Arrays: Mapping an Array

The jQuery method $.map() method lets you use a function to project the contents of an array or a map object into a new array, using a function to determine how each item is represented in the result.

Example: Mapping an Array using jQuery

Give it a TRY! » Note: It returns a newly constructed mapped array


jQuery Arrays: Trimming Text using jQuery

The jQuery function $.trim() is used to remove all whitespaces from the beginning and end of String.

Example: Trimming text using jQuery

Give it a TRY! » Note: It returns a trimmed string


jQuery Array : Merging Arrays

The jQuery function $.merge() is used to merge the contents of two arrays together into the first array.

Example: jQuery Array Merging

Give it a TRY! » Note: It returns an array consisting of elements from both supplied arrays.


jQuery Array : Merging Content using $.extend()

The jQuery $.extend() function is used to merge the contents of two objects into the first object

Example: Merging Contents using $.extend()

Give it a TRY! » Note: It returns a target object after it has been modified