setTimeout + Closures Interview Question 🔥 | Namaste 🙏 JavaScript Ep. 11

  Рет қаралды 651,659

Akshay Saini

Akshay Saini

Күн бұрын

Check out the most frequently asked (setTimeout + Closures in a loop) hot trending JS Interview question. 🔥This question will strengthen your knowledge and understanding of Closures and will also help you in your frontend/full stack/ web development interview. We will start with an easy JS question and slowly move to the hard and tricky interview question.
If you are giving web developer interviews actively, there are high chances that you might find this question in your frotend developer interview. Candidates have faced this question in their interviews for Amazon, Facebook, Paypal, Microsoft and many other big tech firms.
The only request is to watch this Episode of Namaste JavaScript with full attention. 🙏
My tech gear I use every day - google.peek.link/2pba
Timestamps:
00:00 - Introduction - setTimeout & Closures Interview Question
00:19 - Code Begins - Easy Question
03:12 - How setTimeout actually works in JS
04:45 - Most asked Tricky JS Interview Question
06:58 - Importance of Closures
10:15 - Solution to the problem
12:45 - Extension of the interview question
16:50 - Teaser of the next video
17:11 - Thank you for watching Namaste JavaScript 🙏
Support this video series, NOT BY MONEY, but by sharing it with your friends. 🙏
I'll give my best to come up with great content and everything absolutely for free on KZfaq. 😊
If you are active on Social Media,
please give a shoutout to Namaste JavaScript and help me reach more people. 🙏
Cheers,
Akshay Saini
akshaysaini.in
Would love to Stay Connected with you ❤️
LinkedIn - / akshaymarch7
Instagram - / akshaymarch7
Twitter - / akshaymarch7
Facebook - / akshaymarch7
#NamasteJS #AkshaySaini

Пікірлер: 1 200
@abhinav227
@abhinav227 3 жыл бұрын
"Time, tide and JS wait for none" - Want this on my T-shirt 😀
@ravindrakumbhar
@ravindrakumbhar 3 жыл бұрын
😄
@alradiation5417
@alradiation5417 3 жыл бұрын
Having same thoughts in my mind
@guruprasadsali7402
@guruprasadsali7402 3 жыл бұрын
Same in my mind also
@shreyashsingh101
@shreyashsingh101 Жыл бұрын
abhi now .... naice
@shuvenduoffline
@shuvenduoffline Жыл бұрын
and then 'await' comes 😂
@deepakdesai5662
@deepakdesai5662 3 жыл бұрын
3 years of coding in JavaScript and now i know that i don't know javascript properly 😂. Thank you bro tune meri aankhe khol di🤩
@tanyagoel9140
@tanyagoel9140 3 жыл бұрын
Sir, Please make series on React as well. Will be highly appreciated :)
@srujanashankar9517
@srujanashankar9517 3 жыл бұрын
Yes React please
@aimanzaheb1475
@aimanzaheb1475 3 жыл бұрын
And also make it relative with namaste js series.
@roothacks6864
@roothacks6864 3 жыл бұрын
Yes we need a series on react just like this it will be very helpful
@sahilarora7186
@sahilarora7186 3 жыл бұрын
Exactly. akashay bro. Waiting for it.
@Nikkupikku123
@Nikkupikku123 3 жыл бұрын
yes we need "Howdy React!" :P
@AmanMishra-pn3cq
@AmanMishra-pn3cq 2 жыл бұрын
Things learned: 1. setTimeout stores the function in a different place and attached a timer to it, when the timer is finished it rejoins the call stack and executed. 2. Without closure the var reference gives the latest value as it does not retain the original value but rather has the reference so any update in value after timeout will be shown. 3. If we use let/const because they have block scope, every time a new copy of variable is attached, thus this can be done without closure.
@kushagrashrivastava2846
@kushagrashrivastava2846 Жыл бұрын
6:57 function y(){ for(var i=1;i
@chriskatanic8080
@chriskatanic8080 Жыл бұрын
@Kushagra Shrivastava All of the timers start at the same time, not one after the other. So the first logs to the console after 1 second, the second after 2 seconds, the third after 3 seconds, etc. This makes them print one second part from each other.
@kushagrashrivastava2846
@kushagrashrivastava2846 Жыл бұрын
@@chriskatanic8080 thank you so much
@stephen2824
@stephen2824 Жыл бұрын
If we use const, you will find that his example prints 1 once, then throws an error. It is a constant and can not be changed after that, i.e. it is not a changeable “variable” in a true sense, so it is a misnomer.
@SaiKumar-fi1ll
@SaiKumar-fi1ll Жыл бұрын
@@stephen2824 ya true
@sravankumar-hv3lp
@sravankumar-hv3lp 3 жыл бұрын
Your passion to teach is awesome. We can clearly see it in your eyes you want to help others to grow rather than earning money by sharing your knowledge. ❤️
@akshaymarch7
@akshaymarch7 3 жыл бұрын
Thank you brother ❤️
@saicharan2159
@saicharan2159 Жыл бұрын
@@akshaymarch7 Love you Bro for this knowledge sharing ❤
@aroundtheglobeSwati
@aroundtheglobeSwati 3 жыл бұрын
Some tough concepts well handled and it's always so fun to watch as the way you keep the viewers glued to the video. I have never used JS before but now I feel that I should start doing some programs related to it for practice. I never got the idea of craziness of viewers towards this series , now I do realize their excitement for "Namaste JS". Kudos!!
@atif5752
@atif5752 3 жыл бұрын
This is most literally the most simplified explanation on closure and this question over the internet. As usual just amazing and thanks a ton, man
@nikhil6842
@nikhil6842 3 жыл бұрын
Interviewer asked me exactly this question, but i didn't know. But thanks to the knowlege i got from your other videos, i was able to convince them to hire me. Thank you Akshay, for everything you've done and everything you'll be doing in the future. World needs more people like you, who not only are successful themselves but also guiding others and making their journey a lot easier.
@akshaymarch7
@akshaymarch7 3 жыл бұрын
❤️
@merlinwarage
@merlinwarage 2 жыл бұрын
Why would you go to an interview without reading a book about the subject? All of these things are almost in every JS book.
@HominisLupis
@HominisLupis 2 жыл бұрын
@@merlinwarage lol
@harshshukla_5544
@harshshukla_5544 2 жыл бұрын
@@merlinwarage can you please recommend me a good js book
@sushantthakur413
@sushantthakur413 3 жыл бұрын
Great job Akshay, I am myself a javascript developer and love JavaScript, u really inspiring, doing a grt job not only in educating them but explaining them these tough concepts so that even kindergarten child can understand, really amazed to see your passion . God Bless you.
@Aman-gw7ro
@Aman-gw7ro 2 жыл бұрын
got that answer of setTimout running in loop before you printed on console. Very cool example of closures. Seriously man best playlist on JS on youtube.
@aijaz4441
@aijaz4441 3 жыл бұрын
Javascript is tricky but your explanation is so crisp and clear that even a non JS developer can understand it.
@sofiaborovskaia3714
@sofiaborovskaia3714 10 ай бұрын
After reading many articles and watching other videos about closures & loops, I finally understand why we experience this behaviour. The key was to understand that the async function stores the reference and not the value! Thank you, and I love your style of teaching.
@prafulsinghvit
@prafulsinghvit 3 жыл бұрын
Now that you spoke of event loop, we need a video on this topic too 😀 Folks, like this comment if you too want a video on event loop. Thanks!! 🙏
@akshaymarch7
@akshaymarch7 3 жыл бұрын
Haha, you got me. 😅 But don't worry brother, before Event Loop there are few more fundamentals to cover. After covering them, event loop will be a cakewalk. 😎 Pehle thoda mahual banayenge, fir seekhenge. 😇
@lsd3284
@lsd3284 3 жыл бұрын
Event Loops can be understood by JSConf webinars .
@sanjuk3185
@sanjuk3185 3 жыл бұрын
Hey folks, event loop video is out on this channel 3 days ago, check it out.
@gujjugando
@gujjugando 3 жыл бұрын
@@akshaymarch7 isi bat pe hindi me bhi bana do 🤩🤩
@BcomingHIM
@BcomingHIM 3 жыл бұрын
@@lsd3284 true.
@shikharjoshi6349
@shikharjoshi6349 3 жыл бұрын
Bhaiya ye video dekhne k baad jiski job lagegi vo itna kush ni hoga jitna aap thumbnail mein hore 😅. ❤️
@MahendraSingh-od6cp
@MahendraSingh-od6cp 3 жыл бұрын
You explain things in very nice and different way so that everyone can understand, watching this series continuously and enjoying and waiting for new series on React js. You are just making life easy....Keep it up man 👏👏
@farazhusain925
@farazhusain925 3 жыл бұрын
I've completed my master's in mechanical enginnering, and after that, I planned to switch my career in the IT industry. Yesterday, I cracked the first round of interviews for the position of front-end developer. All the questions on JS were from your videos, and I can bet that the interviewer has also watched your Namaste Javascript series.
@manojpatil2457
@manojpatil2457 2 жыл бұрын
What's the update? Have you joined?
@farazhusain925
@farazhusain925 2 жыл бұрын
@@manojpatil2457 I'll join from 6th September. I've cleared one more interview for the position of a front-end developer. Thanks to Akshay once again.
@manojpatil2457
@manojpatil2457 2 жыл бұрын
@@farazhusain925 Wonderful . Which portal you are using for applying?
@ritikraj2629
@ritikraj2629 2 жыл бұрын
is react also asked in that
@farazhusain925
@farazhusain925 2 жыл бұрын
@@ritikraj2629 Yes
@priyeshjammula854
@priyeshjammula854 3 жыл бұрын
The whole Namaste JS series feels like dope and the meme at the end of this video just mimics that!!! Hats off to you Akshay.
@rishabhshukla5199
@rishabhshukla5199 3 жыл бұрын
I did exact same mistake what he expected and got output as all 6. What an amazing concept you taught. You expressions while teaching 😍.
@amarnathmishra8697
@amarnathmishra8697 Жыл бұрын
You are amazing as always brother . Nobody understands the hard work you have done off screen , referring so many resources and books , making masterpiece videos are also challenging and time consuming. Completed Season 1 play list . switching gear to season 2 .
@ashwini.r.
@ashwini.r. 3 жыл бұрын
I like the way how you added memes/gif in between... put some smile while we're concentrating to learn concepts. Thank you for making us understanding JS.
@bhautikmavani4416
@bhautikmavani4416 3 жыл бұрын
Your namaste javascript series is like web series. I know all JS concept still i am watching your video. it's really fun. keep on #JS#GURU
@akshaymarch7
@akshaymarch7 3 жыл бұрын
You're a champ!
@rupalisingh4804
@rupalisingh4804 3 жыл бұрын
Every time you smile, I smile..that too while learning javascript😂. What a great teacher❤
@nitin0001
@nitin0001 3 жыл бұрын
I was already aware of the question and output but didn't know how to fix this problem. You explained it very beautifully
@kartikshrivastava1500
@kartikshrivastava1500 Жыл бұрын
I always thought that only C++ template spaghetti has something mind bending to offer, but now I have a purpose to learn JS. Thank you Akshay bhai!
@rohanmangale5990
@rohanmangale5990 3 жыл бұрын
Man...I was searching the whole internet to understand this problem from months none i could understand. And today you made me understand it in just 17 minutes hats off to u man....u are a gem
@akshaymarch7
@akshaymarch7 3 жыл бұрын
❤️
@arunvishwakarma2779
@arunvishwakarma2779 3 жыл бұрын
The problem with Akshay is that, He has positive radiating energy. You can't stop watching his videos :D
@thomasshelby4544
@thomasshelby4544 2 жыл бұрын
I wish everyone has this problem :)
@animeshsharma9932
@animeshsharma9932 3 жыл бұрын
I am binge watching NAMASTE JAVASCRIPT and look forward to do the same next weekend also. The best JS course in the world right now.
@vidurwadhwa6897
@vidurwadhwa6897 3 жыл бұрын
Great explanation dude! I am myself guilty of hating javascript for a long time because I thought it was kind of stupid but now I see there is a reason behind everything.
@sudo-codm
@sudo-codm 2 жыл бұрын
This is the kind of teacher I have been waiting all life.
@laurraileanu8374
@laurraileanu8374 3 жыл бұрын
on the 11th clip in a row, just trying to remember this for an interview. great content man, your energy is actually making me want to write some functions and just play with them, I have never seen easier explanations of the execution context, hoisting and closures. Kuddos man
@user-kv4sp2zk6c
@user-kv4sp2zk6c Жыл бұрын
hey , did you clear the interview ? was the questions asked were covered in this playlist ?
@known878
@known878 4 ай бұрын
i think he is dead....he might have committed sucide bcoz he is not replying @@user-kv4sp2zk6c
@siddhartharoy179
@siddhartharoy179 3 жыл бұрын
I got so excited when I saw this because I stumbled upon this exact problem some time back while I was working on a sorting visualizer project and couldn't figure out what was wrong with my code for days. Ultimately someone advised me to use async and await but now i fully understand why that didn't work.
@ravalravi882
@ravalravi882 3 жыл бұрын
I always watch traversy media, web dev simplifed , dev ed and all (and i always think that no one is that good enough for javascript from india).. but you prove me wrong .. Thank you bro keep making video like this..
@ashishpandeyone
@ashishpandeyone 3 жыл бұрын
Akshay, lovely explanation, awesome outro music. Now Liggi is going to be on a loop today. 😂
@aniketshukla8085
@aniketshukla8085 10 ай бұрын
// In below case, close is getting called for each value of i. And for each close() called a new execution context is getting created and in execution phase of that context new callback function context is created with lexical environment, which is reffering to i with which close() was called as close(i) was immediate parent of that callback function. Above cycle goes on and on until for loop ends. function clock(){ for(var i = 1 ; i
@priyam86f
@priyam86f 5 ай бұрын
you saved my day my man. what a wonderful explaination. you dived right back to the basics..thanks!!
@brothersumitkumar
@brothersumitkumar 3 жыл бұрын
🔥 Awesome! It looks like you have revealed someone's secret in the manner you explained timeout function memory location concept. Great sir🙏
@mamtagarg2263
@mamtagarg2263 Жыл бұрын
Aksahy, your videos are so informative and interesting that sometimes I don't like to press LIKE button just not to interrupt the flow you are teaching. Really big THUMSUP to your videos 👍. Thanks!!
@killadasatyaaditya2396
@killadasatyaaditya2396 2 жыл бұрын
Do note that the timer can expire before the whole loop gets executed when you change the stopping condition from i
@solowolf5304
@solowolf5304 2 жыл бұрын
can anyone plz help me why the suggested solution in video of using let (a block scope variable) variable isn't working here : function z ( ) { let a = 10 ; a++ ; setTimeout( () => { console.log(`from setTimeout : ${a}`) ; }, 600); console.log(`from last console log : ${++a}`) ; } z() ; my output is : from last console log : 12 from setTimeout : 12 expected output : from last console log : 12 from setTimeout : 11
@bandishkumar1990
@bandishkumar1990 2 жыл бұрын
@@solowolf5304 function z ( ) { let a = 10 ; a++ ; function local(x) { setTimeout( () => { console.log(`from setTimeout : ${x}`) ; }, 600); } local(a) console.log(`from last console log : ${++a}`) ; } z() ;
@Test-wi3mj
@Test-wi3mj 2 жыл бұрын
@@solowolf5304 function z ( ) { let a = 10 ; let b = a++ ; b++ setTimeout( () => { console.log(`from setTimeout : ${b}`) ; }, 600); console.log(`from last console log : ${++a}`) ; } z()
@akshayghogare4563
@akshayghogare4563 2 жыл бұрын
@@solowolf5304 please carefully look for....++I and I++ .
@ManishKumar-oe5bb
@ManishKumar-oe5bb 2 жыл бұрын
@@solowolf5304 inside setTimeout the value of a is also 12 because the time it's going to log a value, it's already updated to 12 . function inside setTimeout remembers the a's reference not value. So at a's memory the value is updated to 12. So it is printing 12.
@sachinbahegavankar
@sachinbahegavankar 3 жыл бұрын
Finally I found 1 channel which sales diamond's and it is free.
@ganeshbardade6464
@ganeshbardade6464 3 жыл бұрын
Thank you brother 🙏. Just few days ago, this question asked by interviewer 💻. and I gave same what same answer like "It will increment variable i after some m/sec". That time she told me I was wrong. But watching your video💻, now I 💡clear everything. and also now I understand "var and let" can make such change. Thank you again 😇✌️👏
@rameshsuthar4341
@rameshsuthar4341 3 жыл бұрын
Your "Namastey Javascript" series has made me fall in love with Javascript.. Thank you Akshay Saini for this wonderful series.
@shubhamsaurabh2631
@shubhamsaurabh2631 2 жыл бұрын
Bhai ek number videos hai apke. I have not watched this full video yet, currently on 05:03 minutes. I just decided to try to take this up as a coding challenge and got the desired result. You have explained the concept of closure so damn well. More power to you man.
@DK-ox7ze
@DK-ox7ze 3 жыл бұрын
"Many senior engineers will pull their hair over this". Well, if you don't know about the asynchronous nature of Javascript, you aren't senior!
@pratikkumar939
@pratikkumar939 3 жыл бұрын
Exactly
@kavinkumar
@kavinkumar 3 жыл бұрын
This isn't async nature of js dude
@nikhiltomar4543
@nikhiltomar4543 3 жыл бұрын
wastage of time
@viralpasad5222
@viralpasad5222 3 жыл бұрын
Such an amazing mentor. All your videos deserve at least a million views.
@durgaprasaddas6494
@durgaprasaddas6494 2 жыл бұрын
I've an interview scheduled today yet I'm watching this playlist, my confidence is getting higher with completing every video
@priyanshagarwal2095
@priyanshagarwal2095 3 жыл бұрын
6:10 😂 SAVAGE 🔥 "That's how it is not.."
@akshaymarch7
@akshaymarch7 3 жыл бұрын
Haha 😂
@ashutoshguleria5968
@ashutoshguleria5968 Жыл бұрын
For those having dfficulty like me in understanding why each iteration creates its own closure or stores i in a separate memory space unlike var. You can think of each iteration of for-loop like a mini function almost, with new/different value of i (1,2,3,4,5) and and since let is block scoped (block scope meaning within the curly braces of each mini-function) it stores reference to i at different place (different closure made by different mini-functions). Also that, a closure closes over or captures the current scope when the callback function is passed to setTimeout.. But why does it closes over when call back function is called? Because a closure is formed when a function is created inside another function and the inner function has access to the outer function's variables and parameters.
@taskeen_fatimaa
@taskeen_fatimaa Жыл бұрын
thankyou I was able to understand the concept but your view made my concept more clear
@SalmanMalik-w2x
@SalmanMalik-w2x 5 күн бұрын
i tried understanding this concept by watching it several times in this week but finally after watching it now, i hope i can say understood the 80% of concept in this video. Btw extremely Thank full to you you created content of this high notch quality.
@avijeetkumar7092
@avijeetkumar7092 3 жыл бұрын
Great man !! Working with JS be like learning new things every day...and your videos are a great to boost in that :-)
@gokunik
@gokunik Жыл бұрын
One more way to solve that problem: function x(i) { var a = i; setTimeout(() => {console.log(a);}, a * 1000); } for (var i = 0; i < 5; i++) { x(i); } This makes the function more dynamic.
@dhinakaransaravanan9472
@dhinakaransaravanan9472 Жыл бұрын
You are a great man 🎉
@paadaghattam
@paadaghattam Жыл бұрын
you dont need var a there..
@kakadiazeel
@kakadiazeel 3 жыл бұрын
"Wherever I go, I see him" - Closures
@darkthrongrising5470
@darkthrongrising5470 2 жыл бұрын
This is the best JS series, I foresee you becoming a great JS master.
@saipavaninagisetti5286
@saipavaninagisetti5286 3 жыл бұрын
Wow!!!!! Finally, I get to understand setTimeout + Closures properly! :) Thank you so much!
@lovishchib
@lovishchib 2 жыл бұрын
Akshay explains confusing stuff: "You will pull your hair" Baldie me: give me something else, I don't wanna play
@UMBERELLA_ACADEMY
@UMBERELLA_ACADEMY 2 жыл бұрын
I think you still got some hairs, dig deeper🌝
@divyanshuchauhan4527
@divyanshuchauhan4527 6 ай бұрын
@@UMBERELLA_ACADEMY 😂😂😂😂😂😂😂😂😂😂😂😂😂😂😂😂😂😂😂😂😂😂😂😂😂😂😂😂
@vatsalkhanna3597
@vatsalkhanna3597 3 жыл бұрын
Oh my god! I had an interview today and the interviewer asked this. The first question in JS he asked was this. But I didn't know it. 😐
@akshaymarch7
@akshaymarch7 3 жыл бұрын
Next time, aag laga dena mere dost!! 🔥
@tanyacharanpahadi158
@tanyacharanpahadi158 3 жыл бұрын
WOOWWWW! the clarity.🔥
@shubhis2466
@shubhis2466 2 жыл бұрын
This video gave me answers to everything that I have been searching for many days. Thank you so much for such a detailed explanation. :)
@prakashbtw678
@prakashbtw678 3 жыл бұрын
Yes bro crt, many interviewer asked this question
@sahul._
@sahul._ 2 жыл бұрын
To be simple, Let is block scoped and also function scoped, But var is function scoped not block scoped
@xpointer483
@xpointer483 3 жыл бұрын
Wonderful video as always! Your explanation of closure is far easier to follow. But in the last example where you enclosed the function within another function, was the desired result possible because functions in Js are passed by reference of memory location and not by value? If so, then why wasn't the settimeout ''function'' creating different memory locations?
@subhamshaw1726
@subhamshaw1726 2 жыл бұрын
loving this playlist. awesome and i had became victim of this question in past. Thanks to you, now I can understand and solve this type edge cases
@tommysingh7546
@tommysingh7546 3 жыл бұрын
We could also make use of IIFEs here to create a closure. Its basically the same as creating a wrapper function and explicitly calling it as shown in the video for(var i=0; i
@kirtikhohal3313
@kirtikhohal3313 2 жыл бұрын
wow....great
@sathishpai4868
@sathishpai4868 3 жыл бұрын
I knew the answer, when you questioned. That's because of your previous video explanation on Closures, block scope, global scope. Thank you very much Akshay.
@sarthakghosh4690
@sarthakghosh4690 6 ай бұрын
I was asked this question at an interview with DeliveryHero. Brilliant!
@murali-krishnan
@murali-krishnan 6 ай бұрын
Great man, did you crack the job? How many rounds of interviews did you go through and what were those rounds?
@mohansingh-kx4rf
@mohansingh-kx4rf 2 жыл бұрын
Highly appreciated man. Just a note, to solve the problem with var , you are calling function with value not a reference. Problem will remain same if you pass the reference if I. Btw thank you for efforts.
@meetakbari9897
@meetakbari9897 3 жыл бұрын
Thank you Akshay for making it simple to understand. I have one doubt: You have mentioned timeout to x*1000, so why every output like 1 2 3 ... is printing after exactly 1 second even if x is incrementing?
@agrawalmahesh616
@agrawalmahesh616 2 жыл бұрын
when the settimeout was executed in the current execution, at that time the value passed to the settimeout function was 1000, 2000 and so on. so based on that value the timer is confugured in the background thread. when the variable is used to manipulate, it gives output as single value which is 1000, 2000 etc. you are not keeping reference of that variable. thats why it was printing aftet 1, 2, 3 seconds.
@surenderoati
@surenderoati 2 жыл бұрын
Because, Only the inner function part is put somewhere else not the whole setTimeout function. Akshay sir, please correct me if i am wrong.
@jv1994
@jv1994 2 жыл бұрын
may be running this will clear you doubt for (var i = 1; i < 4; i++) { const r = parseFloat((Math.random()*10).toFixed(2)); const timeOut = parseInt((i + r) * 1000); console.log(i, timeOut, r); setTimeout(function () { console.log('var', i, new Date().toLocaleTimeString()) }, timeOut); }
@sahej97
@sahej97 3 жыл бұрын
Learning: never use var in js, unless almost necessary Var will mess your code beyond recognition
@chandracoder8645
@chandracoder8645 3 жыл бұрын
very true!
@kajalpareek8291
@kajalpareek8291 3 жыл бұрын
Hi Akshay, Thanks for the last example I was literally scraching my head because this question have been asked to me by most of the interviewers and I got answers online but couldn't understand. But now thanks to you.
@ManishSharma-jz2hw
@ManishSharma-jz2hw 3 жыл бұрын
Amazing Akshay!! Aspire to know JS like you. One day, I will, for sure. Love you man. ❤️
@akshaymarch7
@akshaymarch7 3 жыл бұрын
Please watch this video with UTMOST ATTENTION. Listen to each line very carefully. 🙏 Next Video: CRAZY JS Interview 🤯 - kzfaq.info/get/bejne/qpeeeaR-3NmZdn0.html Also, do let me know will you be able to answer this question in the interview now? ✌🏽
@akshaymarch7
@akshaymarch7 3 жыл бұрын
@revking I don't have a full plan myself. 😅JavaScript is huge, very huge, very very huge. I'm very confused, what to cover and what not to. If I start covering everything then this series will become a ` while(true){ makeVideo(); } ` 😅 But I'll definitely think about important topics and try to come up with Long Term Vision and a roadmap for Namaste JavaScript. 👍 Thank you so much for your comment, brother. ❤️
@EeshaKPopDanceCovers
@EeshaKPopDanceCovers 3 жыл бұрын
Akshay 'this' keyword is very confusing in js..🙄🙄
@vinothkumarv9722
@vinothkumarv9722 3 жыл бұрын
Exactly : ) finally the music is awesome.....
@vinothkumarv9722
@vinothkumarv9722 3 жыл бұрын
@@EeshaKPopDanceCovers even me also
@vinothkumarv9722
@vinothkumarv9722 3 жыл бұрын
@@akshaymarch7 this line If I start covering everything then this series will become a ` while(true){ makeVideo(); } ` >>> super bro :) love you :) ❤️❤️❤️❤️❤️❤️❤️
@EmpatheticPriya
@EmpatheticPriya Жыл бұрын
Its actaully best quotes time,tide and JavaScript wait for none.😂 now I totally understand setTimeout because of your teaching is awesome. lots of respect for you
@faizanmuhammad802
@faizanmuhammad802 6 ай бұрын
Awesome! A small quiz: "closures keep reference not the actual value" (repeat it 10 times) and guess the output of below snippet for(var i=1; i { console.log(i); i = i + 1; }, i*1000); } console.log("outside: ", i) if( i < 10 ) i = 10;
@viswesh3939
@viswesh3939 5 ай бұрын
outside:6 // The for loop get executed before the setTimeout func 10 11 12 13 14 //after the for loop execution now the " i " value become 10 and the value in settimeout has the value 10 beacuse of lexical scope .
@syedsheralihussain
@syedsheralihussain 3 жыл бұрын
6:26 panic sets in. 😭 11:07 relief. 😊
@akshaymarch7
@akshaymarch7 3 жыл бұрын
This shows how patiently you watched the video, brother! ❤️
@sktwister14
@sktwister14 3 жыл бұрын
Why does it create a new copy when we are using let? In every loop iteration the variable i remains the same, it is just that its value increases and is stored at the same place. Why is setTimeout unable to access just the reference to i variable and behave the same as var? Why is there a new copy associated? I did not understand why it happens just because it is block scoped. The timeout function will always have "let i" with it since it is always present in its lexical env just like a var variable.
@jasonbrody4618
@jasonbrody4618 3 жыл бұрын
Me too he just said block scoped but he didn't explain how it's new variable not even in his block scope video. If you know can you explain?
@raufurkhan9191
@raufurkhan9191 Жыл бұрын
@@jasonbrody4618 I too dont understand. Can Anyone explain this.?
@sergiisechka1993
@sergiisechka1993 2 жыл бұрын
Of course I'm excited! I like the way you teach! Amazing!
@harshitmishra8788
@harshitmishra8788 3 жыл бұрын
Sir, you are great.. You just explain the major concepts of JS in such a simple way. Please make video on ReactJs..please.
@tanishqgupta1652
@tanishqgupta1652 3 жыл бұрын
You made me pull my hair so many time, I am bald now. What to do? :p
@akshaymarch7
@akshaymarch7 3 жыл бұрын
🥺 Don't worry brother, this will help you - amzn.to/2VUgHAu
@RoshanKrSoni
@RoshanKrSoni 3 жыл бұрын
@@akshaymarch7 😂😂
@AviatorBro
@AviatorBro 3 жыл бұрын
@@akshaymarch7 😂😂😂
@mukeshgaud2603
@mukeshgaud2603 3 жыл бұрын
@@akshaymarch7 grt sir this solution will enclose his baldness.
@sg3558
@sg3558 3 жыл бұрын
4 solutions to this question 1. Use let instead of var 2.use iife 3.Bind the callback function with the value ofi 4.move i to outer function with let
@vinothkumarv9722
@vinothkumarv9722 3 жыл бұрын
U mean 2 poin variable life time' u saying right
@sudonitin
@sudonitin 3 жыл бұрын
Most underrated mentor out there..... 🔥🔥🔥
@yatendraupadhyay2180
@yatendraupadhyay2180 5 ай бұрын
Never ever learnt such topics man . This teacher is on a different level.
@MrudulSankhere
@MrudulSankhere 2 жыл бұрын
First of all, beautiful series. Amazing work giving the in-depth knowledge of JS Concepts. Thank You very much. Question: In the block of for loop when loop variable is declared using 'let', you mentioned that in each iteration, a new copy for variable i is created. i++ executes by going to the reference of the variable and then adding 1 to it. I want to understand when the new reference is created? after i++ executes and it enters the for loop? Or when the loop body ends? Also, is there a separate instance in this case just adding to the value of i and creating a new instance with the corresponding value in that loop? Basically, I understand that in each iteration a new memory address is assigned. I don't understand when this process of creating new reference executes. 1. loop body ends, new reference created, old memory freed, i++ executes? OR 2. i++ executes, new reference created with updated value, old memory freed, loop body starts? Which of these is the correct order?
@rahulkulkarni9653
@rahulkulkarni9653 3 жыл бұрын
recently i have an interview with HCL and the have asked the same question .... i have answered like you ha ha ha they have very much impressed even interviewer doesn't know in-depth thanks buddy you are great ........ please continue this
@bhagyashreepani4059
@bhagyashreepani4059 3 жыл бұрын
Sir you explaining so nicely , please keep posting such fundamental videos , it really helps!!
@RoshanKrSoni
@RoshanKrSoni 3 жыл бұрын
my interviewer asked the same & that time i was stuck on it. thanks for making me understand 😍
@debarshidas8678
@debarshidas8678 Жыл бұрын
This is the best Javascript playlist in the entire universe!
@kshitishchandrajha2711
@kshitishchandrajha2711 3 жыл бұрын
So interviewer frame questions from this playlist got it!!! Let next interview come...
@_MAHFUJHOSSAIN
@_MAHFUJHOSSAIN 3 жыл бұрын
This video makes my understanding of block scope clearer. Thank you
@mshahzebraza
@mshahzebraza 2 жыл бұрын
Great Tutorial Akshay! You're doing a great job. Please Continut making this awesome content!
@Guhaaloks
@Guhaaloks 3 жыл бұрын
How awesome "Let" is, this video is just amazing and informative, Thanks AS
@Davyhatesu
@Davyhatesu Жыл бұрын
I have never laughed at a tutorial till now! Keep the humor up in your videos brother!
@deepakvincent
@deepakvincent 3 жыл бұрын
Amazing bro.. I have been working with JS for 4 years.. Finally I understood what closure was. Thank you
@akshaymarch7
@akshaymarch7 3 жыл бұрын
Not yet, next video will cover more about closures. 🔥
@molyoxide8358
@molyoxide8358 Жыл бұрын
Was working on DrumKit Project as a newbie to JS got frustrated when I got stuck in the "for loop". Thanks a lot for explaining.
@WestcolColombia_
@WestcolColombia_ Жыл бұрын
I will remember closures for ever, yeahhhhh!!!!! 🏆🏆❤️❤️❤️❤️❤️❤️❤️❤️❤️
@RohitPal-lz1wf
@RohitPal-lz1wf Жыл бұрын
Because of your lectures, most of interviewers now know, What to ask and how to check in-depth knowledge and understanding of candidate.
@gayathrireddy7715
@gayathrireddy7715 3 жыл бұрын
I would have watch this video earlier.. Everytime when I was attending the the closure concept was appearing in the question list and everytime I confused a lot even I read I remember the code without understanding.. Thank you!
@vibhugautam5093
@vibhugautam5093 3 жыл бұрын
Ohh bhai!!! Maza aa gya!!! "Oh ma go..tru love..."
@ayushtripathi429
@ayushtripathi429 3 жыл бұрын
Pure Gold!
@thegamingrecoil7931
@thegamingrecoil7931 3 жыл бұрын
Bhai zabarzast kamak kar diya
@karthikpuvvula
@karthikpuvvula 2 жыл бұрын
This is the best explanation on this topic and the best channel on youtube for javascript.. Thanks brother 🙏🏾
@beastboy..
@beastboy.. 3 жыл бұрын
Brother you explain each and every complex topics with ease.👍👍👍👍👀👀👀 thanks..
@ayushagarwal1584
@ayushagarwal1584 Жыл бұрын
sir you're amazing teacher please keep making these types of courses for us, it really helps ❤
CRAZY JS INTERVIEW 🤯ft. Closures | Namaste 🙏 JavaScript Ep. 12
32:45
Closures in JS 🔥 | Namaste JavaScript Episode 10
22:44
Akshay Saini
Рет қаралды 794 М.
Fast and Furious: New Zealand 🚗
00:29
How Ridiculous
Рет қаралды 43 МЛН
WHAT’S THAT?
00:27
Natan por Aí
Рет қаралды 14 МЛН
10 JavaScript Interview Questions You HAVE TO KNOW
13:41
James Q Quick
Рет қаралды 51 М.
Learn Closures In 13 Minutes
13:22
Web Dev Simplified
Рет қаралды 58 М.
JavaScript Interview questions everyone gets wrong
6:40
Catherine Li
Рет қаралды 26 М.
map, filter & reduce 🙏 Namaste JavaScript Ep. 19 🔥
37:42
Akshay Saini
Рет қаралды 876 М.
BLOCK SCOPE & Shadowing in JS 🔥| Namaste JavaScript 🙏 Ep. 9
19:57
Beginner React.js Coding Interview (ft. Clément Mihailescu)
36:31
Ben Awad
Рет қаралды 2,1 МЛН