Preparation Code Preparation HTML (this will be inserted in the <body>
of a valid HTML5 document in standards mode) (useful when testing DOM operations or including libraries) <script src ="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.4.4/underscore-min.js" > </script >
<script src ="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/1.1.1/lodash.min.js" > </script >
<script >
var lodash = _.noConflict ();
</script >
Setup JS var numbers = [];
var object = {};
for (var i = 0 ; i < 20 ; i++) {
numbers[i] = i;
object['key' + i] = i;
}
var objects = _.map (numbers, function (n ) { return { 'num' : n }; });
var randomized = _.sortBy (numbers, function ( ) { return Math .random (); });
Teardown JS
Test cases
Test #1 Title *
Async
Code * var timesTwo = [];
_.each (numbers, function (num ) { timesTwo.push (num * 2 ); });
Test #2 Title *
Async
Code * var timesTwo = [];
lodash.each (numbers, function (num ) { timesTwo.push (num * 2 ); });
Title *
Async
Code * var timesTwo = [];
_.each (object, function (num ) { timesTwo.push (num * 2 ); });
Title *
Async
Code * var timesTwo = [];
lodash.each (object, function (num ) { timesTwo.push (num * 2 ); });
Title *
Async
Code * _.keys (object);
Title *
Async
Code * lodash.keys (object);
Title *
Async
Code * _.map (objects, function (obj ) { return obj.num ; });
Title *
Async
Code * lodash.map (objects, function (obj ) { return obj.num ; });
Title *
Async
Code * _.pluck (objects, 'num' );
Title *
Async
Code * lodash.pluck (objects, 'num' );
Title *
Async
Code * _.values (objects);
Title *
Async
Code * lodash.values (objects);