Analyzing the designated parameter $ .isArray () is a function of whether the array. Returns a Boolean value.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> </head> <body> <div class="box"></div> <div class="box"></div> <script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.js"></script> <script> console.log($('.box')); var res = $.isArray($('.box')); console.log(res); </script> </body> </html>
Another example -
arr = [1,2,3,4]; res = $.isArray(arr); console.log(res);
Return: true
$ .InArray () to find the specified value in the array, and returns the index of the first occurrence (not found, returns -1) source array is not affected
It takes three arguments, the first is what you're looking, and the second is to find the target array, a third of the value specified search start position (including the position of the current value)
For chestnut (¯, ¯)
arr = ['hello',5,5,'hello',8]; res1 = $.inArray('hello',arr); console.log(res1); res2 = $.inArray('hello',arr,2); console.log(res2);
res1:0
res2: 3