Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function test() {
- const array = [];
- for (let i = 0; i < 10000000; i++) {
- array.push(Math.random());
- }
- console.time("For");
- for (let i = 0; i < array.length; i++) {
- array[i] * 10;
- }
- console.timeEnd("For");
- console.time("For of");
- for (let item of array) {
- item * 10;
- }
- console.timeEnd("For of");
- console.time("For each");
- array.forEach(item => {
- item * 10;
- });
- console.timeEnd("For each");
- }
- for (let i = 0; i < 10; i++) {
- test();
- console.log("--------");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement