42:35 This is because the var keyword does not have block scope, so the variable i is still accessible outside of the for loop. By the time the setTimeout functions run, the for loop has already finished and the value of i is equal to 10. The value of a[10] is undefined, so that is what will be logged to the console.
This is because the setTimeout function is an asynchronous function that will not block the execution of the rest of the code. Therefore, when the console.log statement inside the function is executed after the delay of 1 second, the value of i will have already reached 10, which is outside the index range of the array a. As a result, a[i] will evaluate to undefined for all iterations.
The var provide the global and the let provide the local scope in the javascript part. that is why is provide the undefined for the let and value for the var keywords.
The provided code will output undefined ten times. This happens because the setTimeout function is asynchronous, and by the time the callback is executed, the value of i has reached 10, which is outside the valid index range for the array a.
I'm searching for MERN stack interview questions... i want to apply for Full stack..but backend interview ke bare me abhitak thik se koi prepration nahi hai... please suggest me
42:35 This is because the var keyword does not have block scope, so the variable i is still accessible outside of the for loop. By the time the setTimeout functions run, the for loop has already finished and the value of i is equal to 10. The value of a[10] is undefined, so that is what will be logged to the console.
This is because the setTimeout function is an asynchronous function that will not block the execution of the rest of the code. Therefore, when the console.log statement inside the function is executed after the delay of 1 second, the value of i will have already reached 10, which is outside the index range of the array a. As a result, a[i] will evaluate to undefined for all iterations.
42:37 loop only exits until the set condition breaks.
And the function is called after 1000ms so the variable is already incremented to 10.
thanks bro
a[10] does not exits
@@ashishnimrot9221 bro in loop condition is i
The var provide the global and the let provide the local scope in the javascript part. that is why is provide the undefined for the let and value for the var keywords.
Well explained
I found no where like it amazing
The provided code will output undefined ten times. This happens because the setTimeout function is asynchronous, and by the time the callback is executed, the value of i has reached 10, which is outside the valid index range for the array a.
Undefined, because const is block scope, it's not working in another block, because for loop also creating block.
Thanks for the help
thank you
Really very useful sir, please make react js interview questions as well very helpful sir. Thank you
did they asked you about the projects u have completed before and to show on their desktop
Nice question🙋
Thanks
Thanks
Kaun si company hai ye
I'm searching for MERN stack interview questions... i want to apply for Full stack..but backend interview ke bare me abhitak thik se koi prepration nahi hai... please suggest me
don't worry First give interview, diffidently you will qualify , minor diff b/w MERN and Fullstack.
Thank you so much for sharing question 👍
My pleasure
In youtube I don't find much MEAN stack projects ... So can you recommend me some place where i can find projects on MEAN stack
The output is undefined because of closure concept in Java script..
Sir these questions for, how much experience
2 to 5 years experience
Sir, please make more videos 👍
Sure I will
Bro aapka experience kitna tha interview ke time?
3 years
Completely murkh or logo ko murkh bna ra...