in JavaScript by
Q:

Guess the outputs of the following codes:

// Code 1:

function func1(){

  setTimeout(()=>{

    console.log(x);

    console.log(y);

  },3000);

  var x = 2;

  let y = 12;

}

func1();

// Code 2:

function func2(){

  for(var i = 0; i < 3; i++){

    setTimeout(()=> console.log(i),2000);

}

}

func2();

// Code 3:

(function(){

  setTimeout(()=> console.log(1),2000);

  console.log(2);

  setTimeout(()=> console.log(3),0);

  console.log(4);

})();

Related questions

0 votes
asked Jan 13, 2020 in Big Data | Hadoop by AdilsonLima
0 votes
asked Jun 26, 2019 in Continuous Deployment by SakshiSharma
0 votes
asked Oct 20, 2019 in Other by KeshavVyas
0 votes
asked Feb 6, 2020 in JavaScript by rajeshsharma
0 votes
asked Jan 27, 2020 in JavaScript by AdilsonLima
0 votes
0 votes
...