Convert Object to Array with Angular

Benchmark created by Blackhole on


Preparation HTML

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.4/angular.js"></script>

Setup

var myObj = {
      1: 1 + 2 + 3,
      2: [4, 5, 6],
      3: {
        '7': 7,
        '8': 8,
        '9': 9
      },
      4: '10, 11, 12',
      5: true,
    };

Test runner

Ready to run.

Testing in
TestOps/sec
Angular
var array = [];
angular.forEach(myObj, function(element) {
  array.push(element);
});
ready
Native
var array = Object.keys(myObj).map(function(k) {
  return myObj[k]
});
ready

Revisions

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

  • Revision 1: published by Blackhole on