Skip to content

Instantly share code, notes, and snippets.

@sagivo sagivo/foo.js
Created Jun 2, 2016

What would you like to do?
benchmark of vs in
'use strict';
const timer = function(name) {
var start = new Date();
return {
stop: function() {
var end = new Date();
var time = end.getTime() - start.getTime();
console.log('Timer:', name, 'finished in', time, 'ms');
var a = [];
for (var i = 0; i < 1000000; i++) {
let foo = 0;
var t = timer('using of');
for (const i of a) foo = i;
var t = timer('using in');
for (const i in a) foo = i;

This comment has been minimized.

Copy link
Owner Author

sagivo commented Jun 2, 2016

Timer: using of finished in 61 ms
Timer: using in finished in 220 ms

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.