JSFiddle - React, Tailwind, and code Playground

by Alexander Branchugov

JavaScript

"use strict";

for(var i = 0; i < 10; i++) {
  setTimeout(
    (function(i) {
    	return function() {
      	console.log(i)
      }
    })(i),
    i * 1000
  )
}

function f(i) {
setTimeout(function() {
  	console.log(i)
  },
  i * 1000
  );
}