jQuery inArray() method Last Updated : 31 Jul, 2024 Summarize Comments Improve Suggest changes Share Like Article Like Report This inArray() Method in jQuery is used to search for a specific value in an array and return its index (or -1 if not found). SyntaxjQuery.inArray(val, arr [, Index])Parameters The inArray() method accepts three parameters that are described below: val: The value to search in an array.arr: Any array like object.Index: Index of the array from which to begin search.Return ValueIt returns the index of element in an array, or -1 if element not found. Example 1: In this example, the inArray() method searches an element 30 in the array. HTML <!DOCTYPE HTML> <html> <head> <title> jQuery inArray() Method </title> <script src= "https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"> </script> </head> <body> <script> let arr = [10, 20, 30, 40, 50, 60]; let val = 30; let index = $.inArray(val, arr); console.log(index); </script> </body> </html> Console Output:2Example 2: In this example, the inArray() method searches an element 30 in the array. The index attribute is also passed to search the element from index 3 and return -1. HTML <!DOCTYPE HTML> <html> <head> <title> jQuery inArray() Method </title> <script src= "https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"> </script> </head> <body> <script> let arr = [10, 20, 30, 40, 50, 60]; let val = 30; let index = $.inArray(val, arr, 3); console.log(index); </script> </body> </html> Output:-1 Comment More infoAdvertise with us Next Article jQuery inArray() method P PranchalKatiyar Follow Improve Article Tags : JQuery jQuery-Methods Similar Reads JQuery | isArray() method This isArray() Method in jQuery is used to determines whether the argument is an array. Syntax: jQuery.isArray( object ) Parameters: The isArray() method accepts only one parameter that is mentioned above and described below: object : This parameter is the object to test whether or not it is an arra 2 min read JQuery | isFunction() method This isFunction() Method in jQuery is used to determines if its argument is callable as a function. Syntax: jQuery.isFunction( value ) Parameters: The isFunction() method accepts only one parameter that is mentioned above and described below: value : This parameter is the value to be tested. Return 2 min read JQuery map() Method This map() Method in jQuery is used to translate all items in an array or object to a new array of items. Syntax: jQuery.map( array/object, callback )Parameters: This method accepts two parameters which are mentioned above and described below: array/object: This parameter holds the Array or object t 2 min read JQuery | type() method This type() Method in jQuery is used to determine the internal JavaScript [[Class]] of an object. Syntax: jQuery.type( obj ) Parameters: The type() method accepts only one parameter that is mentioned above and described below: obj: This parameter is the object to get the internal JavaScript [[Class] 2 min read JQuery | isPlainObject() Method This isPlainObject() Method in jQuery is used to check to see if an object is a plain object. Syntax: jQuery.isPlainObject( obj ) Parameters: This method accept a single parameter that is mentioned above and described below: obj: This parameter holds the object that will be checked to see if it's a 2 min read Like