title: How to break foreach loop in javascript?
body: <p>I have an object <strong>mobile_specs</strong> which have several fields such as DeviceName, Brand, Camera.
  I loop though the <strong>mobile_specs</strong> object so that i can print the specifications of two mobiles in tabular format:</p>
  
  <pre><code>var i=0;
  Object.keys(mobile_specs).forEach(function(key) {
                         if(i==5)
                         {
                          break;
                         }
                        var mobile1=mobile_specs.[key];
                        var mobile2=mobile_specs.[key];
                        alert(mobile1 + " " +mobile2);
                        i++;
                  });
  </code></pre>
  
  <p>But the above code give me an error which is:</p>
  
  <pre><code>Illegal break statement
  </code></pre>
  
  <p><strong>How can i break my loop when i==5 ?</strong></p>
  
  <p>Any help is appreciated. </p>