-
-
Save connor4312/07da143059161a301292b0fe5951f0c1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// run with `matcha bench.js` | |
const cars = ['Tesla', 'Tata', 'Ford', 'Land Rover', 'Audi']; | |
let x; | |
bench('for-let', () => { | |
for (let i = 0; i < cars.length; i++) { | |
x = cars[i]; | |
} | |
}); | |
bench('forEach', () => { | |
cars.forEach(car => { | |
x = car; | |
}); | |
}); | |
bench('for of', () => { | |
for (const car of cars) { | |
x = car; | |
} | |
}); | |
bench('for in', () => { | |
for (const car in cars) { | |
x = car; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment