Advertisement
shopnilSS

hoisting_eventLoop

May 17th, 2021 (edited)
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. console.log(name);
  2. console.log(age);
  3. hello()
  4.  
  5. setTimeout(()=> {
  6.     console.log("I am from setTimeOut One console log 3 sec");
  7.     setTimeout(() => {
  8.         console.log("I am from setTimeOut Three console log 3 sec");
  9.         setTimeout(() => {
  10.             console.log("I am from setTimeOut Four  2 sec");
  11.             setTimeout (() => {
  12.                 console.log("I am from setTimeOut Five 5 sec" );
  13.             },5000) //Five 4 sec
  14.         }, 2000) // Four 2 sec
  15.         setTimeout(() => {
  16.             console.log("I am from setTimeOut Four 3 sec ");
  17.             setTimeout (() => {
  18.                 console.log("I am from setTimeOut Six 4 sec" );
  19.             },4000) //Six 4 sec
  20.         }, 3000) // Four 3 sec
  21.        
  22.     }, 3000) //Three 3 sec
  23.    
  24.     setTimeout(() => {
  25.         console.log("I am from setTimeOut Three console log 2 sec");
  26.     }, 2000) //Three  2 sec
  27.    
  28. }, 3000) //One
  29.  
  30. setTimeout(() => {
  31.     console.log("I am from setTimeOut Two 2 sec");
  32. }, 2000) //Two
  33.  
  34. function hello(params) {
  35.     console.log("I am from hello function");
  36. }
  37. var name = "shopnil"
  38. let age = 5
  39.  
  40.  
  41. //output
  42. /* 1.undefined
  43. 2.refferance error
  44. 3."I am from hello function"
  45. 4."I am from setTimeOut Two 2 sec"
  46. 5."I am from setTimeOut Three console log 3 sec"
  47. 6."I am from setTimeOut Three console log 2 sec"
  48. 7."I am from setTimeOut Three console log 3 sec"
  49. 8."I am from setTimeOut Four  2 sec"
  50. 9."I am from setTimeOut Four 3 sec"
  51. 10."I am from setTimeOut Six 4 sec"
  52. 11."I am from setTimeOut Five 5 sec"
  53. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement