title: How to get the closest element from a javascript array using jQuery?
body: <p>I have a javascript array like this</p>
  
  <pre><code>var array1= [10,20,30,40,50];
  </code></pre>
  
  <p>Is there any method using which i can get the closest array element to a given number ? Ex: if i pass 26, It should return 30 ( 26 is closest to 30). If i pass 42, It should return 40.</p>
  
  <p>Any thoughts ? Should i iterate thru each elements ? Is there any methods available for this in jQuery ?</p>