title: Count length of Array having 'non numeric indexes only' without for in loop
body: <p>Array defines length=0 if the indexes are non numeric.</p>
  
  <p>I came across this implementation of getting length but still i fear to use for in loop for arrays. Most of the places for in loop is instructed as 'bad practice'.
  <a href="https://stackoverflow.com/questions/2265167/why-is-forvar-item-in-list-with-arrays-considered-bad-practice-in-javascript">see here</a></p>
  
  <p>Is it okay to implement like this?</p>
  
  <p>Can someone provide alternate solution(without for in loop)?</p>
  
  <p><b>any example with for loop?</b></p>
  
  <p>I have used <code>hasOwnProperty(..)</code> method to avoid properties of <code>Array.prototype</code>.</p>
  
  <pre><code>Array.prototype.global = 1;
  
  var arr = [];
  arr['first'] = 1;
  arr['second'] = 2;
  
  console.log(arr.length);  //0
  
  var length = 0;
  for(index in arr){
     if(arr.hasOwnProperty(index)) {length++;}
  }
  
  console.log(length); //3
  </code></pre>