for..in vs for..in..if (v64)

Revision 64 of this benchmark created by Sam on


Description

This test compares speeds of 'for..in' in two forms.

Preparation HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<script src="http://documentcloud.github.com/underscore/underscore-min.js">
</script>
<script>
  var arr = [],
      loop = 5000;
  
  var fn = function(x) {
      x = x;
      };
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
for..in
for (var i in arr) {
  fn(arr[i]);
}
ready
for..in..if
for (var i in arr) {
  if (arr.hasOwnProperty(i)) {
    fn(arr[i]);
  }
}
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.