Closures in JS 🔥 | Namaste JavaScript Episode 10

แชร์
ฝัง
  • เผยแพร่เมื่อ 7 ก.พ. 2025

ความคิดเห็น • 1.6K

  • @sougandikal6022
    @sougandikal6022 3 ปีที่แล้ว +1406

    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 :) :)

    • @Sksahu_123
      @Sksahu_123 3 ปีที่แล้ว +2

      Thanks

    • @pranjalrathod2158
      @pranjalrathod2158 3 ปีที่แล้ว +6

      Buddy, was it necessary to be rude?

    • @dandalasuman
      @dandalasuman 3 ปีที่แล้ว +6

      You put it in beautiful words

    • @sss-kd9md
      @sss-kd9md 3 ปีที่แล้ว +1

      @@pranjalrathod2158 rude? Who?

    • @pranjalrathod2158
      @pranjalrathod2158 3 ปีที่แล้ว +10

      @@sss-kd9md that guy deleted the comment now. Let's ignore

  • @ogs3721
    @ogs3721 3 ปีที่แล้ว +524

    Four things I like about Akshay.
    1) Doesn't try and speak in an American accent, like most Indian TH-cam programmers.
    2) Passionate
    3) Someone with real knowledge.
    4) A talented teacher.

    • @akshaymarch7
      @akshaymarch7  3 ปีที่แล้ว +63

      Love you! ♥️

    • @isaacprosper6295
      @isaacprosper6295 2 ปีที่แล้ว +23

      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

    • @Prajjwal1010
      @Prajjwal1010 2 ปีที่แล้ว +3

      That's what make him unique!

    • @us-xf3kk
      @us-xf3kk ปีที่แล้ว +12

      you mean Hitesh choudhary ?

    • @sanjaygangwar2508
      @sanjaygangwar2508 ปีที่แล้ว +3

      @@us-xf3kk 🤣

  • @akshaymarch7
    @akshaymarch7  4 ปีที่แล้ว +50

    Next Video: setTimeout + Closures Interview Question 🔥 - th-cam.com/video/eBTBG4nda2A/w-d-xo.html
    Kaisa laga video? Are you feeling excited? Let me know in the comments below. ❤️

    • @AdarshSingh-qd6mq
      @AdarshSingh-qd6mq 4 ปีที่แล้ว

      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...

    • @riteshranjan5313
      @riteshranjan5313 4 ปีที่แล้ว

      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.

    • @prathamsinghal5261
      @prathamsinghal5261 4 ปีที่แล้ว

      Jhakaas jhakaas jhakaas

    • @iamsarojb
      @iamsarojb 4 ปีที่แล้ว

      Great. The way you teaching is Great.

    • @EeshaKPopDanceCovers
      @EeshaKPopDanceCovers 4 ปีที่แล้ว

      Amazing and very detailed as always..😊😊

  • @farazhusain925
    @farazhusain925 3 ปีที่แล้ว +347

    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.

    • @mrankushtechnical
      @mrankushtechnical 3 ปีที่แล้ว +15

      Wow😂 bro..

    • @akshaymarch7
      @akshaymarch7  3 ปีที่แล้ว +55

      Congratulations, Faraz. You’re inspiration to many! ♥️

    • @farazhusain925
      @farazhusain925 3 ปีที่แล้ว +24

      @@akshaymarch7 Thanks bro. I've joined that company on 6th September. Apart from that, I got one more offer as front-end developer.

    • @kishorburkul3368
      @kishorburkul3368 3 ปีที่แล้ว +5

      @@farazhusain925 i m looking for job as front end developer can you help me how to find it

    • @Indiankarnataka
      @Indiankarnataka 3 ปีที่แล้ว +5

      @@farazhusain925 I am also looking for job as front end developer recently I have completed HTML CSS and JavaScript presently i am learning reactjs

  • @biltten5786
    @biltten5786 4 ปีที่แล้ว +431

    Rest of the world : JS is hard and crazy
    Akshay : hold my green tea.

    • @AmrithMS
      @AmrithMS 3 ปีที่แล้ว +9

      Hitesh: Hold my ice tea.

    • @Oldstoryhouse
      @Oldstoryhouse 3 ปีที่แล้ว +7

      @@AmrithMS travery media....are u challenging me?

    • @coolspatula2458
      @coolspatula2458 3 ปีที่แล้ว +1

      @@Oldstoryhouse the new Boston..... focking noobs

    • @shubhsharma19
      @shubhsharma19 9 หลายเดือนก่อน

      javascript is the most beautiful language and typescript is legendary with those types

    • @NizamKhan-dx5kj
      @NizamKhan-dx5kj 6 หลายเดือนก่อน

      ​@@Oldstoryhousep

  • @bhanuprasad4952
    @bhanuprasad4952 3 ปีที่แล้ว +161

    My interviewer got impressed when I explained the way you explained. Dude you are a 💎.

  • @ls0359
    @ls0359 ปีที่แล้ว +28

    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

  • @ApintoAApintoA
    @ApintoAApintoA 11 หลายเดือนก่อน +18

    Mainly closures & this keyword helped me land a great new job. Thanks Akshay for creating such a great course (Namaste JS Season 1 & 2). I recommend this series to everyone as a prerequisite towards their frontend job search.

    • @akshaymarch7
      @akshaymarch7  11 หลายเดือนก่อน +6

      Wish you the best, keep rising! 🚀

  • @shikharjoshi6349
    @shikharjoshi6349 4 ปีที่แล้ว +528

    Bhaiya is high on JS 😂. More power to you.

    • @97vaqasazeem
      @97vaqasazeem 4 ปีที่แล้ว +3

      Haha !! So much passion for Javascript . Great !

    • @rupinkhandelwal
      @rupinkhandelwal 4 ปีที่แล้ว

      Indeed! :D

    • @rupinkhandelwal
      @rupinkhandelwal 4 ปีที่แล้ว +1

      Closures is another level

    • @HARIHaran-ks7wp
      @HARIHaran-ks7wp 4 ปีที่แล้ว +1

      High on Javascript and green tea....Snoop Dogg no match xD

    • @KamranKhan-xv4br
      @KamranKhan-xv4br 3 ปีที่แล้ว

      Exactly..

  • @jagrutsharma9150
    @jagrutsharma9150 2 ปีที่แล้ว +22

    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.

    • @Sportgameww
      @Sportgameww 5 หลายเดือนก่อน +1

      bro is everywhere Thank you for this notes.

  • @nikhil6842
    @nikhil6842 4 ปีที่แล้ว +80

    One step closer to Closure.
    Thank you Akshay, I cleared my JS interview because of your videos only.

    • @akshaymarch7
      @akshaymarch7  4 ปีที่แล้ว +13

      Congratulations, brother! ❤️

    • @simcard2732
      @simcard2732 ปีที่แล้ว +1

      I am beginner please give some tips

    • @gk4816
      @gk4816 ปีที่แล้ว

      @@akshaymarch7 comment testing

  • @veerendrajana6444
    @veerendrajana6444 3 ปีที่แล้ว +22

    As a Mechanical Engineer, I'm really enjoying this course. The way you are explaining is simply superb.

  • @ssbrar
    @ssbrar 4 ปีที่แล้ว +9

    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 .

  • @narendrakumariitb
    @narendrakumariitb 2 ปีที่แล้ว +26

    Man how can a student not be excited if the teacher himself is so so much excited. Great video bro

  • @ufuomapokoh413
    @ufuomapokoh413 3 ปีที่แล้ว +21

    this dude makes me fall in love with JS. And, yes. i'll never have to find another video on closures. thanks a million!

    • @ddheena272
      @ddheena272 หลายเดือนก่อน

      i feel the Same too in 2024 now.even though this video got 3 years old.i also feel the same .Let's GET DEEP DIVE INTO THIS.........................................

  • @bharathsh9809
    @bharathsh9809 3 ปีที่แล้ว +1

    Never read or tried to learn JavaScript...
    But, Started directly to work on it and it's been almost 8 years..
    Now these videos are making me realize , why I struggled with those setTimeout n all ..

  • @shivashankar6043
    @shivashankar6043 4 ปีที่แล้ว +403

    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 🙏...

    • @prafulsinghvit
      @prafulsinghvit 4 ปีที่แล้ว +16

      JavaScript itself is vast, but yeah once he completes that...may be he can put a udemy course for React.
      😀

    • @rupinkhandelwal
      @rupinkhandelwal 4 ปีที่แล้ว +4

      That would be awesome!

    • @unknownworld4950
      @unknownworld4950 4 ปีที่แล้ว +73

      Vote for reactjs :D

    • @CodeWithYubraj
      @CodeWithYubraj 3 ปีที่แล้ว +48

      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.

    • @rashmitapinto4175
      @rashmitapinto4175 3 ปีที่แล้ว +3

      Yes pleaseeee

  • @MrMohfeez
    @MrMohfeez 3 ปีที่แล้ว +11

    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.

  • @ruditrahul3638
    @ruditrahul3638 3 ปีที่แล้ว +27

    Bhaiya, Please don't ever delete this playlist!!!..This is super helpful and helps me revise it before the interview!!!!

  • @AmmarTheTrainer
    @AmmarTheTrainer ปีที่แล้ว +4

    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.

  • @toskr-r4t
    @toskr-r4t 2 ปีที่แล้ว +7

    Another seriously underrated JS channel. Clear and simple explanation. Thank you Namaste :)

  • @jeannoelhonisch7037
    @jeannoelhonisch7037 2 ปีที่แล้ว +14

    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

  • @priyanshumishra7900
    @priyanshumishra7900 3 ปีที่แล้ว +7

    Brooo never seen anyone teaching online with that excitement!!! This is soo good! the content and the learning :))

  • @Ella438
    @Ella438 หลายเดือนก่อน +1

    Your content is gold. Everytime I need to brush up any concepts I go through the videos on your channel. You are awesome!!!!

  • @peak-naik
    @peak-naik 4 ปีที่แล้ว +38

    Damn bruh! It got aggressive real quick!!!
    Reminds me of that Maths teacher yelling at the screen 😂

  • @adinfinitum03
    @adinfinitum03 ปีที่แล้ว +1

    Studied JS from alot of resources but this man made me fall in love with it , a true guru 🙏🏻, just remarkable

  • @kiruthigarani4850
    @kiruthigarani4850 2 ปีที่แล้ว +9

    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. :)

    • @neerajatokekar1079
      @neerajatokekar1079 2 ปีที่แล้ว +3

      Changing let to var will not work as var is 'function scoped' so we cannot access it outside the function.

  • @sreelekshmiunnikrishnan575
    @sreelekshmiunnikrishnan575 10 หลายเดือนก่อน

    I am doing a full stack developer course online and my mentor suggested your videos.Your videos gave me a lot of new ideas and get to know javascript in depth.Thanks Akshay for your efforts 🙏

  • @technicalbhai235
    @technicalbhai235 4 ปีที่แล้ว +66

    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

    • @akshaymarch7
      @akshaymarch7  4 ปีที่แล้ว +55

      All of these are coming!! 💥

    • @Makeyourselfproud22
      @Makeyourselfproud22 3 ปีที่แล้ว +7

      @@akshaymarch7 we are waiting for these topics

    • @mathanprakash5685
      @mathanprakash5685 3 ปีที่แล้ว +1

      @@akshaymarch7 i am also eagerly waiting for those topics

    • @kalavathithiyagarajan8994
      @kalavathithiyagarajan8994 2 ปีที่แล้ว +1

      @@akshaymarch7 waiting please upload the videos as soon as possible plz bro

    • @nicholasaine7756
      @nicholasaine7756 2 ปีที่แล้ว

      @Akshay Sani . Waiting for these too :)

  • @vipulsinghthakur2514
    @vipulsinghthakur2514 2 ปีที่แล้ว +3

    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.

  • @jeannoelhonisch7037
    @jeannoelhonisch7037 2 ปีที่แล้ว +7

    These videos are amazing. Its the depth, the enthusiasm, the great explainations etc….

  • @youtubecodinggithub6145
    @youtubecodinggithub6145 ปีที่แล้ว

    this is more worth than any tutorials i am sure i got placement for a angular developer in a company they also asked me javascript questions i am sure everyone who is learning this course it's worth always remember react or angular it's just a library of javascript javascript is the main thing learn that deeply like akshay saini tell you all the best thank you akshay love you i am 19 years old now

  • @simrankoul
    @simrankoul 4 ปีที่แล้ว +27

    I have nothing to do with JS, and yet I am watching this as if my life thrives upon it.
    Going great like always! 🤗🤗

    • @akshaymarch7
      @akshaymarch7  4 ปีที่แล้ว +5

      Thank you so much, Simran 🤗

  • @mudassirahmed6220
    @mudassirahmed6220 2 ปีที่แล้ว +1

    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,

  • @shivam12326
    @shivam12326 4 ปีที่แล้ว +17

    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.

    • @akshaymarch7
      @akshaymarch7  4 ปีที่แล้ว +15

      Hahaha 😂
      Ask her to subscribe for more drama. 😂

  • @DurgeshYadav-bc5nm
    @DurgeshYadav-bc5nm 3 ปีที่แล้ว

    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

  • @anupammanitripathi2731
    @anupammanitripathi2731 4 ปีที่แล้ว +16

    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.

  • @priyareddy6743
    @priyareddy6743 18 วันที่ผ่านมา

    Wow. Great explanation. I understood the concept very well. It seems easy for me bkz this is the first time am learning Closures and JS. Glad I started learning JS through your videos. I strongly fell that I saved a lot of time while gaining strong knowledge in JS.

  • @prajjwalsahu793
    @prajjwalsahu793 4 ปีที่แล้ว +7

    If the video would have been 3 hours long I would have seen it with full enthusiasm.
    Thanks Akshay sir.
    Keep posting.

  • @EstheticallyPathetic
    @EstheticallyPathetic 8 หลายเดือนก่อน

    Woah... I have watched numerous videos on closure. Looking at the 20+ mins duration made me reluctant at first. Halfway through the video and looks like I'm finally able to understand this topic.
    THANK YOU BROTHER ♥

  • @vijaykumarreddyalavala3713
    @vijaykumarreddyalavala3713 4 ปีที่แล้ว +4

    Akshay Saini is on a mission to make all of us great at JS. Thank you so much man

  • @syedkamranshah1212
    @syedkamranshah1212 3 ปีที่แล้ว +1

    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.

  • @KevinHoltabc
    @KevinHoltabc 3 ปีที่แล้ว +8

    Really love your energy! Your content is really helping with my interviews!!

  • @aayushtyagi4916
    @aayushtyagi4916 11 หลายเดือนก่อน

    i am learning js from last 1 year but never understand js in so much depth. Now i can say that i am good in js and have depth knowledge of it. All thanks to you 🥰

  • @asifahmed6568
    @asifahmed6568 4 ปีที่แล้ว +33

    Only Legends would Binge watch This series😎 #JS😘😀😁

  • @ashishdeora8522
    @ashishdeora8522 2 ปีที่แล้ว +1

    Coding from last 11 years and never seen this beauty of JS. Thank you so so much 💖

  • @akarshsrivastava8890
    @akarshsrivastava8890 4 ปีที่แล้ว +29

    Finally, today I can sleep peacefully. We won over closure after watching this video. 😅

  • @manjunathadharagond9322
    @manjunathadharagond9322 2 ปีที่แล้ว

    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!!

  • @peterstrange1830
    @peterstrange1830 3 ปีที่แล้ว +3

    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!

  • @mohit7717
    @mohit7717 8 หลายเดือนก่อน

    Yes I will able to give answer in my interview now ... when we have returned function it not just the function code return but a closure enclosed alongwith lecxical scope will returned.
    Closure: Function alongwith it's lexical scope forms a closure i.e., known as Closure ❤

  • @mainakmondal8691
    @mainakmondal8691 4 ปีที่แล้ว +5

    Best video on CLOSURE...the energy level and the content🔥🔥🔥...thanks a lot..😎😎

  • @sarveshkulkarni6287
    @sarveshkulkarni6287 9 หลายเดือนก่อน

    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 !

  • @avantikasarkar3175
    @avantikasarkar3175 2 ปีที่แล้ว +4

    You make complex topics feel like a "Hello World" program 🙏. You truly have a knack for teaching.

  • @aravindhvasu195
    @aravindhvasu195 ปีที่แล้ว +1

    Hello, thank you for this mind blowing series!
    I've a doubt regarding closures. Here's my very brief explanation of closures.
    - A Closure "space" is created, apart from the Execution Context, whenever a reference to any variable or function is made from an inner function, so that even the EC of outer function goes out of scope, we've access to the required variables. So It contains the function bundled with the lexical env.
    My doubt is regarding the "space", I don't exactly understand what a closure is physically in memory. Is like an execution context or just a separate space or something else.
    Once again thanks a lot for this amazing content.

    • @kirtikhohal5025
      @kirtikhohal5025 ปีที่แล้ว +1

      We can assume it to be a separate space in the memory, because we know that variables are stored in memory spaces. And, for sure it is not an execution context. Just like in the memory space we have different sections like - global, local (you must have observed this when a functional execution context is created), script (for hoisting let and const declarations), in the same way closure is also a separate memory space.

  • @swapnil12123
    @swapnil12123 2 ปีที่แล้ว +7

    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
      @akshaymarch7  2 ปีที่แล้ว

      🚀🚀🚀

    • @SahilKumar-xz1xs
      @SahilKumar-xz1xs ปีที่แล้ว

      @@akshaymarch7 Checking nested comments on youtube

  • @ianpropst-campbell6028
    @ianpropst-campbell6028 2 ปีที่แล้ว +1

    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

  • @anshikapathak4422
    @anshikapathak4422 2 ปีที่แล้ว +2

    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.🙏🙏🙏🙏🙌🙌🙌🙌🙌❤️❤️❤️🎉

  • @shigufaaaliya5924
    @shigufaaaliya5924 7 หลายเดือนก่อน

    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!

  • @shaileshparmar3973
    @shaileshparmar3973 4 ปีที่แล้ว +15

    The excitement level is the dam high

    • @mohit96nain
      @mohit96nain 4 ปีที่แล้ว +4

      I was looking for this comment, checking whether it mee or someone else also thinking the same 😂♥️

    • @shaileshparmar3973
      @shaileshparmar3973 4 ปีที่แล้ว +1

      @@mohit96nain yo bro 🤣

    • @KamranKhan-xv4br
      @KamranKhan-xv4br 3 ปีที่แล้ว +1

      @@mohit96nain mee too, thinking of it same 😅

  • @YonoZekenZoid
    @YonoZekenZoid 3 ปีที่แล้ว

    you are probably the only person on youtube with a video on closures who actually knows what closures are, kudos my fellow developer!
    I just want to add, for what it's worth, two things that might be important to understand when doing functional programming in JS:
    1. Closures are bound to the function upon it's declaration. this is what allows them to be returned and have their lexical scope persist after the function that contained them is no longer alive.
    2. Closures only close over their most immediate lexical scope. in the case of your function y(), it is only responsible for creating Closure (x), not Closure (z)... that was created when function x() was declared. the thing is, since closures are themselves lexical scopes, and are mixed into the lexical scope of the function they are declared with upon its invocation, Closure (z) gets passed to y() when it gets invoked through it's own Closure (x).
    This last distinction is very important, as the creation of multiple closures over z() could potentially create multiple versions of b - with different values - if, for example, y were an object with 2 functions, each with a separate closure and a body that manipulated b. It would also make it much harder for the garbage collector to determine when a scope was no longer being used, as it would have to keep track the immediage lexical closures, and any other closures created inside said closures, and so on and so forth.
    I'm only adding this because I think you did a marvellous job of explaining this topic, and want to complement the information you already put forth.

    • @akshaymarch7
      @akshaymarch7  3 ปีที่แล้ว +2

      This is one of the most enlightening comments I’ve got on my videos. It goes even more deep when understanding Closures. Thank you so much, Nicolas. ♥️

  • @the-owls-owlet
    @the-owls-owlet 4 ปีที่แล้ว +36

    I was waiting for this since long 😃 Today I will sleep well ✨

  • @english_with_zaki
    @english_with_zaki 4 หลายเดือนก่อน

    I want to say we love you man! Thank you for all the efforts and time you devote to making awesome videos like this.

  • @chrispusthiaine3735
    @chrispusthiaine3735 2 ปีที่แล้ว +5

    Namasty Bro. I think you're impacting more knowledge than most schools🙏🙏🙏

  • @saumyadixit6860
    @saumyadixit6860 3 ปีที่แล้ว

    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!

  • @rhimanshu6288
    @rhimanshu6288 4 ปีที่แล้ว +5

    "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??

  • @jotarokujo312
    @jotarokujo312 2 หลายเดือนก่อน

    Thank you so much bro!!! I've watching so many videos and reading articles and this is the one that sticks!! I can't believe it was just that simple!

  • @VishalGupta510
    @VishalGupta510 4 ปีที่แล้ว +8

    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.

  • @simple8810
    @simple8810 3 ปีที่แล้ว

    The most amazing thing in Sir Akshay is he explain the exact meaning of each term and usage in coding ,that most developer dont even noticed these things they Just clear how they work but dont know the exact background of each term,And here Sir explain both
    So Bundle of thanks Sir je

  • @vinothkumarv9722
    @vinothkumarv9722 4 ปีที่แล้ว +5

    Vinoth love❤️ >> Akshay:
    One thing i forgot to inform bro dress code And hairstyle is awesome
    And finally End music is Vera level :)

  • @absurdist1330
    @absurdist1330 2 ปีที่แล้ว +2

    Probably the most concise explanation of closures. Awesome teaching!

  • @0xFOXHOUND
    @0xFOXHOUND 4 ปีที่แล้ว +51

    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 : th-cam.com/video/74hA6Q7vPI4/w-d-xo.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

    • @pekalarajesh6147
      @pekalarajesh6147 ปีที่แล้ว

      @0xFOXHOUND
      hello bro can u please explain me why we got the value as 100...not 7
      at 13:30

    • @ajinkyavidwans4134
      @ajinkyavidwans4134 ปีที่แล้ว

      @@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'.

  • @ranikontham8678
    @ranikontham8678 4 หลายเดือนก่อน

    Oh my godd....I fell in love with his explanations of the closure concept. The way he explains the clouse concept was top notch😍

  • @allaboutev6360
    @allaboutev6360 2 ปีที่แล้ว +3

    I have watched 1000 videos before this and i can guarantee you i will not watch again any video of closure again . Thanks Akshay

  • @rodevhit
    @rodevhit 3 ปีที่แล้ว

    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.

  • @ramraghunathan947
    @ramraghunathan947 3 ปีที่แล้ว +31

    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 🥳🥳🥳

  • @nikhildeepsingh2832
    @nikhildeepsingh2832 ปีที่แล้ว +1

    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
    )

  • @ayushipriya3884
    @ayushipriya3884 3 ปีที่แล้ว +3

    Getting to learn a lot. Thank you so much for sharing your knowledge . This course is helping me a lot.

  • @mazharimam9216
    @mazharimam9216 2 ปีที่แล้ว

    Bahut jgh pdha..mdn v dekha tha utne acche se ni smjh aaya but yha full clear hua bhut acche se . Ab refrence aapka v lunga js related.dhywaad aur bhgwaan aapko aise hi aage badhate aur khus rakhe ❤️

  • @aayushipandey7292
    @aayushipandey7292 4 ปีที่แล้ว +17

    He literally treats people who learn other languages as aliens! :D Indeed JS is beautiful.

  • @guruprasadsali7402
    @guruprasadsali7402 3 ปีที่แล้ว

    yesterday i had interview and he ask me closure i was not able to answer him, now i can explain anyone thanks akshay..............kash ye video pehle dekh liya hota

  • @vgcordys
    @vgcordys 3 ปีที่แล้ว +5

    Chitvan(Hope you know the legend): Baba, you are beautiful
    Akshay: JavaScript, you are beautiful 😃

  • @mujamil87
    @mujamil87 ปีที่แล้ว

    I am learning Javascript for Test automation and I am really happy to learn it from basics and how its works internally.

  • @thriftykapila8420
    @thriftykapila8420 4 ปีที่แล้ว +18

    Me (30 mins before interview) - Note that, note that!!!

  • @sagarshekhar6296
    @sagarshekhar6296 9 หลายเดือนก่อน

    Mujhe Closure kisi aise hi passionate instructor se samjh aa sakta tha.....Thanks man

  • @AmanMishra-pn3cq
    @AmanMishra-pn3cq 2 ปีที่แล้ว +9

    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.

  • @haverikakrishna
    @haverikakrishna ปีที่แล้ว

    it was really an amazing video on closure, before watching this video I was struglling to find out what exactly is closure. But now I can confidently say that this is what it need to bee...
    Thank you bhai for this wonderful video...

  • @outzonegaming4554
    @outzonegaming4554 4 ปีที่แล้ว +5

    Dude, nice hairstyle and video.

  • @chenshen4255
    @chenshen4255 ปีที่แล้ว

    Man!!! I like how you are passionate about closure, I wasn't planning to watch the next video, but I will now

  • @nerdycap7513
    @nerdycap7513 4 ปีที่แล้ว +4

    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!

  • @KiranYadavOG
    @KiranYadavOG 2 ปีที่แล้ว +1

    People say communication is the key trait of growth and everything and I could see it today in this session! need to work on it bruh!

  • @cb559
    @cb559 3 ปีที่แล้ว +8

    Senior and cool developers disliked the video because they still didnt get it !

  • @vinisaveg
    @vinisaveg 3 ปีที่แล้ว

    best video series I have ever seen about javascript and it's peculiarities. thank you Akshay Saini!

  • @rohil3023
    @rohil3023 4 ปีที่แล้ว +4

    10:45 😂😂😂😂😂

  • @raxitlakhatariya5915
    @raxitlakhatariya5915 2 ปีที่แล้ว

    Prior to this video, I was expecting closure a rocket science, but Akshay made it so simple. Just amazing

  • @Prakhar281993
    @Prakhar281993 4 ปีที่แล้ว +4

    1:30 you sounded like Arnab Goswamy

  • @tanzirou10
    @tanzirou10 ปีที่แล้ว +1

    00:02 Closures in JavaScript
    02:58 Closures in JavaScript are functions bundled together with their lexical environment.
    05:45 Closures in JavaScript
    08:42 Closures in JavaScript are powerful and allow functions to access variables from higher scopes.
    11:20 Understanding closures in JavaScript
    14:51 Closures in JavaScript can be tricky to understand.
    18:10 Closures in JavaScript are powerful and essential for designing patterns and functions.
    20:35 Closures in JavaScript are powerful and essential for understanding advanced concepts.
    02:58 Closures in JavaScript are functions bundled together with their lexical environment.
    05:45 Closures in JavaScript
    08:42 Closures in JavaScript are powerful and allow functions to access variables from higher scopes.
    11:20 Understanding closures in JavaScript
    14:51 Closures in JavaScript can be tricky to understand.
    18:10 Closures in JavaScript are powerful and essential for designing patterns and functions.
    20:35 Closures in JavaScript are powerful and essential for understanding advanced concepts.

  • @sanathkumar1698
    @sanathkumar1698 4 ปีที่แล้ว +9

    17:05 : "If I call my x"
    Bruh been calling her ,she doesn't pick up, what to do😭😭

  • @Mrnileshagarwal
    @Mrnileshagarwal ปีที่แล้ว

    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.

  • @Abhishek-ko8bf
    @Abhishek-ko8bf 3 ปีที่แล้ว +1

    You are diamond 💎 sir with no doubt .continue this way teaching .I never boarded with your series

  • @rishabhkalra9505
    @rishabhkalra9505 3 ปีที่แล้ว +1

    the moment you said "you will love this" at 3:45s and the expression you gave, that felt like i am really gonna love this :p