Closures in JS 🔥 | Namaste JavaScript Episode 10
HTML-код
- Опубликовано: 30 июл 2024
- Closures in JavaScript is the most important topic for interviews. Even many senior frontend developers don't understand this concept properly. This video will clear all your doubts about closures in js and you will never have to find any other tutorial after this to understand function Closure and Garbage collection. 🔥
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 to Skip the video:
00:00 - Don't skip anything 🙏
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 RUclips. 😊
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
Closure :Function bundled with its lexical environment is known as a closure. Whenever function is returned, even if its vanished in execution context but still it remembers the reference it was pointing to. Its not just that function alone it returns but the entire closure and that's where it becomes interesting !! Thank you so much, Akshay for this :) :)
Thanks
Buddy, was it necessary to be rude?
You put it in beautiful words
@@pranjalrathod2158 rude? Who?
@@sss-kd9md that guy deleted the comment now. Let's ignore
Four things I like about Akshay.
1) Doesn't try and speak in an American accent, like most Indian RUclips programmers.
2) Passionate
3) Someone with real knowledge.
4) A talented teacher.
Love you! ♥️
hes very authentic,first time i thought he was quite weird owing to the fact that im not indian but now i cant get enough of his content
That's what make him unique!
you mean Hitesh choudhary ?
@@us-xf3kk 🤣
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.
Wow😂 bro..
Congratulations, Faraz. You’re inspiration to many! ♥️
@@akshaymarch7 Thanks bro. I've joined that company on 6th September. Apart from that, I got one more offer as front-end developer.
@@farazhusain925 i m looking for job as front end developer can you help me how to find it
@@farazhusain925 I am also looking for job as front end developer recently I have completed HTML CSS and JavaScript presently i am learning reactjs
My interviewer got impressed when I explained the way you explained. Dude you are a 💎.
Wohooo! ✌️😎
Rest of the world : JS is hard and crazy
Akshay : hold my green tea.
Hitesh: Hold my ice tea.
@@AmrithMS travery media....are u challenging me?
@@kingzexperiment the new Boston..... focking noobs
javascript is the most beautiful language and typescript is legendary with those types
Bhaiya is high on JS 😂. More power to you.
Haha !! So much passion for Javascript . Great !
Indeed! :D
Closures is another level
High on Javascript and green tea....Snoop Dogg no match xD
Exactly..
A closure gives access to all the variables of it's parent function even after the that parent function has returned or executed. The function keeps a refernce to it's outer scope which preserves the scope chain throughout the time
As a Mechanical Engineer, I'm really enjoying this course. The way you are explaining is simply superb.
Hi akshay, after complete the Namaste js playlist, please make a playlist for Namaste react. Tons of video out there for react, but your teaching will be easy to grab the core concepts. It's our kind request 🙏...
JavaScript itself is vast, but yeah once he completes that...may be he can put a udemy course for React.
😀
That would be awesome!
Vote for reactjs :D
Voting for React and also for Node.JS and other backend technologies since this man is the only instructor that I have found who cares enough to go in depth and also show behind the scenes kind of stuffs.
Yes pleaseeee
Things learned:
1. Function bundled with lexical scope is called closure.
2. Even if we return the function, it still remembers its original lexical environment and local storage so it can access values.
3. If we write return function x(){.....} --- this automatically returns the value.
4. The function that is returned is reference so any change in value of that variable inside function will be reflected as such.
this dude makes me fall in love with JS. And, yes. i'll never have to find another video on closures. thanks a million!
Bro!! two days back JS is a horror movie for me, now I started liking JS more, lexical scope video is awesome...thanks for your efforts, I like the way how you explain. Credit goes to you.
One step closer to Closure.
Thank you Akshay, I cleared my JS interview because of your videos only.
Congratulations, brother! ❤️
I am beginner please give some tips
@@akshaymarch7 comment testing
i am backend developer and just started to explore frontend tools. No one can explain javascript better then you Sir. all the best, stay healthy and help us all junior developers to learn complicated things. Thanks .
First time landed to your channel in my journey of two years learning and development and I really appreciate the way you explain I was searching for closure and have read blogs watched videos things was clear to me but I was seeking a good definition and you provided it. then explained it very well through the example. Keep it up. Wish you great luck for your future,
i feel like that the creation phase/execution conext is like one of the most crucial concept in js... nearly everything is explainable by creationphase/hoisting and the scopes
Really explained well. I love the enthusiasm of your explanation and your expressions. Really excited for next video. Requesting to cover the topics of generators, iterators.
Topics should be covered. It can help the whole javascript community and me ofcourse.
1. Promises
2. async/await
3. callbacks
4. Polymorphism and inheritance in javascript
5. Memoization
6. Prototype
All of these are coming!! 💥
@@akshaymarch7 we are waiting for these topics
@@akshaymarch7 i am also eagerly waiting for those topics
@@akshaymarch7 waiting please upload the videos as soon as possible plz bro
@Akshay Sani . Waiting for these too :)
One of the finest JavaScript tutorials available, it showcases the art of a talented teacher who effortlessly breaks down complex concepts into easily understandable content.
Brooo never seen anyone teaching online with that excitement!!! This is soo good! the content and the learning :))
Only Legends would Binge watch This series😎 #JS😘😀😁
These videos are amazing. Its the depth, the enthusiasm, the great explainations etc….
Reading Comments on your episodes are just like Goosebumps.. seriously coding is another thing and teaching is another. Your teaching skills are so simple matlab ye direct bheje mai nahi naso mai bhi chala jata hai aap ka sikhaya huaa... lots of ❤️❤️❤️
Bhaiya, Please don't ever delete this playlist!!!..This is super helpful and helps me revise it before the interview!!!!
Man how can a student not be excited if the teacher himself is so so much excited. Great video bro
Really love your energy! Your content is really helping with my interviews!!
I can watch these endlessly, every concept just go into grey matter effortlessly, for the first time I enjoyed learning anything this much ❤️❤️❤️
Whoa! That really cleared up many of my misconceptions regarding closures! Thanks for this series man, it's really helping devs throughout the world!
Akshay Saini is on a mission to make all of us great at JS. Thank you so much man
You make complex topics feel like a "Hello World" program 🙏. You truly have a knack for teaching.
Love this video! Finally I understand what a closure is and can answer with confidence in interviews (I believe so)! and i love your passion and energy, which kept me so awake and attentive and happy! :) Thank you so much!
You are an outstanding Guru !!! Before watching this video, I had watched 5,6 videos but could not understand anything, but you made me know this within minutes! You are a genius!!
Thank-you Akshay. I love watching your videos. You are first and last my favourite instructor of js. Please keep making videos on js advance. I was watching my instructor video around 3 hours but didn't understand not even a single line but when I learnt from you. I understood easily.
Kindly cover
oops
LLD
Promise
Fetch api these kind of topics too. So that we all be good at programing like you.🙏🙏🙏🙏🙌🙌🙌🙌🙌❤️❤️❤️🎉
Another seriously underrated JS channel. Clear and simple explanation. Thank you Namaste :)
can u tell us more underrated JS channels.
Coding from last 11 years and never seen this beauty of JS. Thank you so so much 💖
Studied JS from alot of resources but this man made me fall in love with it , a true guru 🙏🏻, just remarkable
Best video on CLOSURE...the energy level and the content🔥🔥🔥...thanks a lot..😎😎
Getting to learn a lot. Thank you so much for sharing your knowledge . This course is helping me a lot.
I was trying to get this concept since morning by roaming here and there, saw many videos even in hindi which is our mother language and came across your video, and trust me i got it at once😍😍, I didn't had to play your video again and again, it's just your way of teaching is literally awesome and now I got a mentor... Thank you so much man,🥰 All i can feel is if a person could understand english language and still doesn't get what javascript really is by your videos, he/she is not meant for coding.
Loved the video! Closure definition: a function bound together with its lexical environment. This means an inner nested function has access to its parents' lexical scope, and is able to remember variables the were declared in that environment, even after that functions has been removed from the call stack.
You did a very good job of explaining this. I think I've got a ways to go before I totally understand all this stuff though :P
Damn bruh! It got aggressive real quick!!!
Reminds me of that Maths teacher yelling at the screen 😂
Haha, that math teacher was my favorite. 😂
haha! bhut sahi
11:25 I am watching js video along with some cool drama show 🤣🤣. I was watching your video because of js and my sister in class 10 was watching you because of your funny expression.
Hahaha 😂
Ask her to subscribe for more drama. 😂
I watched 3 videos to understand closures and I was lost, but finally understood here, the way you covered every single thing... It is really very helpful. Thank you!
Your teaching skills have made js more interesting for me.I feel so excited to watch every video of namaste javascript.Thank you!
I have been watching his videos in incognito (just the way I am), and didn't even think of liking videos and stuff. but the moment of GREEN TEA. Man, that literally made me open the video in main window, just to comment this. Akshay, you never fail to make videos interesting, be with the kind of energy you put into and the way of explaining things. Nice work. Green Tea man. LOL.
I have nothing to do with JS, and yet I am watching this as if my life thrives upon it.
Going great like always! 🤗🤗
Thank you so much, Simran 🤗
We are pretty much having fun following your course bro! May the ❤ for JS spread across the world.
Thanks to you explaining these topics so well with practical applications in the browser. It helped me a lot understanding how things work behind the scene in JS. Very excited to finish watching this whole playlist.
Today i have seen this chapter and attended an interview. I had a question about closure and i was so excited to answer it, done it successfully but the 2nd question in closure was let scope
function a (){
function b{
let x = 3;
}
function c{
let y = 4;
}
function d{
console.log(x,y)
}
}
now how to change this code to access the x and y variables inside d(), I simply told change let to var, but the suggested answer was we can write like below
function a (){
function b{
let x = 3;
function c{
let y = 4;
function d{
console.log(x,y)
}
}
}
}
However, this helps me lot. :)
Changing let to var will not work as var is 'function scoped' so we cannot access it outside the function.
The excitement level is the dam high
I was looking for this comment, checking whether it mee or someone else also thinking the same 😂♥️
@@mohit96nain yo bro 🤣
@@mohit96nain mee too, thinking of it same 😅
Broo with this excitement i havent seen anyone teaching like this ... its just flawless and easy to grab everything 😍..thank you!
simply blown away , no words can express my gratitude to you for this series
Finally, today I can sleep peacefully. We won over closure after watching this video. 😅
I regularly take interviews, give interviews, I have event watched the entire Namaste JS series multiple times. Still came to this video like 10th may be 12th time to revise closures. This is highly satisfying knowledge. Thanks a lot @Akshay. More power to you :)
🚀🚀🚀
@@akshaymarch7 Checking nested comments on youtube
Superb playlist,I have just started leaning javascript and its amazing that m getting my concepts crystal clear because of this,thanks alottt,and yes m enjoying the playlist and want more content like this,thank you.
I used to be this mush excited about javascript, but now i am kinda stuck with .net core for a while. But i absolutely love javascript and closures. watched this videos because of the good old memories. Nostalgic!! Still remember the way i explained it to my juniors
Namasty Bro. I think you're impacting more knowledge than most schools🙏🙏🙏
"Microservices architechture", I think you should cover this, reason being most of us are very confused about what it actually is, how to use it and where??
Akshay what you are doing is just next level,no one explains the concepts deeply.thank you so much for these videos.
The way you explain it seems the js is in your nerves and it's flowing. It also seems you are teaching yourself, I have seen many videos regarding JS but no one tried and dedicatedly explained the way you are. Keep growing, learning and teaching.
If the video would have been 3 hours long I would have seen it with full enthusiasm.
Thanks Akshay sir.
Keep posting.
❤️
I was waiting for this since long 😃 Today I will sleep well ✨
True.
Me2😀
Wow amazing bro....
Same here...!! Excited..!!!
This video literally deserves a million likes, not even kidding.
Thank you so much making it so simple to understand, sir!
Your videos are so well explained yet concise. You rock, man! Thanks for contributing and giving back!
How tough the subject is. Its not a matter. If we find a good master. We can make it! Akshay a legend! My master u r! I m learning js. One day definitely will get a job.i will put in this comment box.credits to u master!
Next Video: setTimeout + Closures Interview Question 🔥 - ruclips.net/video/eBTBG4nda2A/видео.html
Kaisa laga video? Are you feeling excited? Let me know in the comments below. ❤️
awesome video, earlier for long i am running from JS but now truly i am enjoying learning JS and exploring more, tons of thanks to you...
Thank you, it is a great help, I am preparing for the interview for the role of a frontend developer.
I was waiting for this topic for so long since you have covered it is a great help.
Jhakaas jhakaas jhakaas
Great. The way you teaching is Great.
Amazing and very detailed as always..😊😊
Probably the most concise explanation of closures. Awesome teaching!
Mujhe Closure kisi aise hi passionate instructor se samjh aa sakta tha.....Thanks man
I recently started Javascript , i have previously worked with Java , Php , C++ and shell scripting. I was having tough time with javascript. Even the simplest operation which work in other languages were behaving differently in JS. Recently i was look for delegation in Javascript, I watched many videos but had no clue what delegation was and then i came upon your video of JS delegation and you explained it so well . Then i started Namaste JavaScript its amazing you explain concepts so well and with the knowledge of new concepts i was able to figure out why JS was giving me trouble in simple code. I think Namaste JavaScript should be made mandatory for people coming to javascript with previous programming experience.
And you look and sound like my classmate....
I
A function along with its lexical environment forms a closure. Lexical scope means the references that function was associated with, which means that whenever a function forms a closure it is bound to remember the references it was created with initially(the part in the code where it is called does not matters in case of closures
)
Finally I understood what exactly the closure is.
The way you explained this concept is 🔥.
I am lovin' this series
He literally treats people who learn other languages as aliens! :D Indeed JS is beautiful.
I love Aliens. ❤️
@@akshaymarch7 i love AYushi
@@currentadda7884 bhai chill lol
For revision :
Q)What is closure?
A)The function bundled with its lexical environment closed to that function
simply function + Lexical environment
and closures have very special place in runtime environment
The fun in JavaScript is you can assign a variable for a function and also you can pass function as a parameter even you can return the function in JavaScript!!
Myself : ruclips.net/video/74hA6Q7vPI4/видео.html
Q)What does the closure do in my JavaScript programs?
A) Whenever I call a function in JavaScript the closure maintains its values(lexical env.) and function in its own runtime and when that specific function executed, it returns with own environment even the variable vanished after its execution
11:36 : Simaran! because is on Diet
13:54 : as variable value is changed before executing the return (the function) Value will be 100
In closures, values in variable are 'pass by reference' hence there values can be changed, and whenever comes the closure inside closure(multilevel one) we can see the function refers the 'parent' variable
My Response 21:38
@0xFOXHOUND
hello bro can u please explain me why we got the value as 100...not 7
at 13:30
@@pekalarajesh6147 Since the assignment of the value '100' was after the declaration of the function 'y', but was before the actual function call. When the function 'x' was executed, the assignment 'a = 100' was processed, and the reference to 'a' is what persists, not the actual value at 'a'.
the excitement in his voice makes this video enjoyable while learning!
지렸습니다 진짜 이정도로 깨우쳤다는 느낌을 받은 것은 처음입니다 속이 시원하네요 감사합니다
Vinoth love❤️ >> Akshay:
One thing i forgot to inform bro dress code And hairstyle is awesome
And finally End music is Vera level :)
Kudos for explaining this important concept.
But mentioning things like y remembers the reference of a is vague, better will be to mention how a is stored in memory and how y is able to acess that reference outside x.
Nice point
The way of explanation is awesome Akshay bro.. It gives us to feel like the much interactive session. Definitely I will refer to my friends. Thanks a bundle for your great time on these beautiful videos
I'm thoroughly enjoying learning from your Namaste Javascript series! Your videos are incredibly helpful, and I'd love to see more of them. Could you please consider creating a series on Namaste Angular as well? It would be fantastic to delve deeper into this topic with your guidance!
Me (30 mins before interview) - Note that, note that!!!
I have watched 1000 videos before this and i can guarantee you i will not watch again any video of closure again . Thanks Akshay
Watching it for second time , with same amount of satisfraction , Your teaching way if so unique that , Your definations just hit the mid point of the brain which saves the content automatically !
Thank you for simplifying this topic. It was one of my interview questions and couldn't answer. After watching this video, I'm more confident with closures.
Chitvan(Hope you know the legend): Baba, you are beautiful
Akshay: JavaScript, you are beautiful 😃
Things Learned:
1. Function bundled with its lexical environment is known as a closure.
2. Whenever function is returned, even if its vanished in execution context but still it remembers the reference it was pointing to. Its not just that function alone it returns but the entire closure and that's where it becomes interesting.
Literally got goosebumps at some point when the concept was so much well explained by you and so well understood by me! Awesome way of explaining things man :D . Also when you requested to give a like on this video, thought If I could contribute some money for your videos because these videos reaching to me without any cost(sorry for adBlocker) is pretty undigestable.
Prior to this video, I was expecting closure a rocket science, but Akshay made it so simple. Just amazing
UPDATE : SERIOUSLY GOT A JOB BECAUSE OF THIS ! NOT KIDDING THIS TIME !
Went to an interview.
Interviewer: Write an example of closure.
Me: Wrote down this example
Interviewer: Namaste Javascript ? 🤨
Me: 😐
Interviewer: Even I have the same example in mind.
High five'd each other. Happily working ever after 🥳🥳🥳
hahha
Hahaha😂😂
Dude, nice hairstyle and video.
You are diamond 💎 sir with no doubt .continue this way teaching .I never boarded with your series
The best explanation ever 💯💯 I have learned more concepts in this series as well as how can I share my knowledge in front of interviewer🤝 I'm still watching videos in loop and every time I'm getting new idea's out of these example🤍 Thank you so much Akshay guru ji🙏
It wasn't a green tea, it was a cocktail of JS pills, cocaine, and steroids. The man is on a killing spree in this video. Great fuckin' work!
Senior and cool developers disliked the video because they still didnt get it !
😅
Your approach of giving an info is just amazing, don't know would I understand if not you! thanks!
The best JS video.....I have ever watched....Engaging, fun, and very well explained. Many thanks!
Sir react series
1:30 you sounded like Arnab Goswamy
Hahaha 😂 😂
I love your enthusiasm and your crystal clear explanations. I am now getting excited too!
I feel like a javascript God came in my life. Previously I feel like why this is happening now points clear and things are really in good shape and keeps on moving. You are sooper dooper real hero of javascript hats off👒