Most Asked JavaScript Interview Questions | SetTimeout & EventLoop | JS Interview Series

Поделиться
HTML-код
  • Опубликовано: 2 янв 2025

Комментарии • 35

  • @adityagautam1217
    @adityagautam1217 Год назад +14

    Those who are trying to understand this might help:
    the for loop will complete all iterations before any of the setTimeout functions are executed because setTimeout is an asynchronous function . As a result, the value logged for i in all three iterations will be 3.
    if we change var to let, output will be 0,1,2
    because in case of let a new block scope is created for each iteration of the loop. This means that each iteration of the loop will have its own separate lexical environment and its own distinct value whereas in case of var, it does not create a new block scope, there is only one i variable shared across all iterations of the loop as var is function scoped.

    • @shagunjaiswal3403
      @shagunjaiswal3403 10 месяцев назад

      video se jada acha tummhare code ne samjha diya

  • @RajYadav-yh7vv
    @RajYadav-yh7vv 2 года назад +19

    worst incomplete poor explanation of event loop and bro toda normal raho aur dialogue toda kam kiya karo

  • @parth1450
    @parth1450 2 года назад +8

    I am still waiting for your exact explanation..
    Bhai tho slow details me bana do video..tho acha hoga ..
    Ye video kab shuru hoke khatm hua pata hi nai chala..
    This is genuine feedback don't take it otherwise 👍

    • @careerwithgaurav
      @careerwithgaurav  2 года назад +2

      Hi, Sure have noted dow will make video on this again soon in JS series for beginners which is currently in progress.

    • @buggplayer2301
      @buggplayer2301 Год назад

      true and lesss content and more promotion

  • @animeshdey6289
    @animeshdey6289 2 года назад +4

    Callstack works on LIFO not FIFO

  • @BhaveshBarskar
    @BhaveshBarskar Год назад

    another way to get desired result is to - change var to let it will print 0,1,2

  • @fatimaiqra2169
    @fatimaiqra2169 3 месяца назад

    thanks

  • @jagadishprasad4142
    @jagadishprasad4142 11 месяцев назад +1

    not working, throwing error while executing online jscompiler

  • @imkir4n
    @imkir4n Год назад

    u earned my sub,thank u

  • @jagadishprasad4142
    @jagadishprasad4142 11 месяцев назад

    for(var i=0; i

  • @ambupadamuduli3794
    @ambupadamuduli3794 3 года назад +2

    Thanks for this.we want more questions like this

  • @ravikumarchaudhari1606
    @ravikumarchaudhari1606 2 года назад

    thank you for this osm video

  • @techupdate03
    @techupdate03 2 года назад +2

    Use let instead of var.. output will be 0,1,2

    • @FreeSkypeGenerator1
      @FreeSkypeGenerator1 2 года назад

      thanks for the pointer

    • @mohakmaheshwari8756
      @mohakmaheshwari8756 2 года назад

      interviewers don't let you change it two let and const , self calling function is the only way

  • @ArnavSingh-im5bj
    @ArnavSingh-im5bj 2 месяца назад

    Or you can use let

  • @mohakmaheshwari8756
    @mohakmaheshwari8756 2 года назад +1

    two times i got this function that fucked up my interview

  • @bromptonhorsing8597
    @bromptonhorsing8597 2 года назад +2

    Why do you use English title and then speak another language in the video?

  • @girishpandey2936
    @girishpandey2936 2 года назад

    thanks sir

  • @PURRAHARAAMI
    @PURRAHARAAMI 2 года назад +3

    kya smjhaya bhai tune??? kuch smjh nhi ayaa

  • @RohitSharma-iq8ne
    @RohitSharma-iq8ne 3 года назад +1

    sir var ki jgh let krne pr 012 answer kiyo a rha he

    • @BhaveshBarskar
      @BhaveshBarskar Год назад

      because "let" keyword is blocked scoped, so for every iteration value of new copy of i is passed to closure function i.e setTimeout().

  • @misterl8129
    @misterl8129 3 года назад +5

    damn, dont understand the language

  • @codewithkaran8860
    @codewithkaran8860 2 года назад

    1 question answer is 333

  • @prasandeep6999
    @prasandeep6999 Год назад

    Bhai kya bolna chaha raa hai? Jaldi Bol Kal Subah Panvel Nikalna Hai...

  • @sachinsharma1755
    @sachinsharma1755 2 года назад +1

    bhai interviewer kya sochega usse chodo wo btao jo tum soch rha hao, uske dimaag mai rhen do ki wo kya puchega

  • @petvinnie
    @petvinnie 2 года назад

    3

  • @amarnathmishra8697
    @amarnathmishra8697 Год назад

    Galat maat batao bhai its discouraging!!

  • @jaysinghsolanki7094
    @jaysinghsolanki7094 5 месяцев назад

    Abe mere bhai explain toh kya bakwaas youtuber hai

  • @bhaveshgupta7736
    @bhaveshgupta7736 Год назад

    10min waste kr die mere

  • @adityagautam1217
    @adityagautam1217 Год назад

    not a good explaination

  • @patilrahul515
    @patilrahul515 Год назад

    Rude..