title: Can I return a value just before a certain element of any array in javascript?
body: <p>let's say I've an array, I know the index of a certain element probably like this. </p>
  
  <pre><code>arr.indexOf(num);
  </code></pre>
  
  <p>The num is the argument of a function,and I know where it belongs by using the above code.
  however I want to return the value of an element which is just before <code>arr.indexOf(num)</code>. May be something like this:</p>
  
  <pre><code>arr.indexOf(num)-1 
  </code></pre>
  
  <p>For example, </p>
  
  <pre><code>var arr=[1,4,num,7,9];
  </code></pre>
  
  <p>I should return the value <code>4</code>, which is the closest element of num in that array. </p>