JavaScript/jQuery equivalent of LINQ Any() with $.grep - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:grep

Description

JavaScript/jQuery equivalent of LINQ Any() with $.grep

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript" src="https://code.jquery.com/jquery-1.6.js"></script> 
      <script type="text/javascript">
    $(window).load(function(){//  ww  w.  jav  a  2  s.  c  om
var array = [ 1, 5, 12, 31, 7, 69 ];
var array = $.grep(array, function(n, i) {
  return (n == 5);
});
console.log(array.length);
    });

      </script> 
   </head> 
   <body>  
   </body>
</html>

Related Tutorials