In this code, th e outer function returns a reference to the inner function by using return inner. This is called returning a function as a value, or returning a function reference. If the outer function had used return inner(), it would have returned the result of invoking the inner function instead of a reference to the function itself. This means that the fn variable would be assigned the value returned by inner(), which is undefined since the inner function does not return anything. By returning a reference to the inner function, we can assign it to the fn variable and then call it multiple times using the fn() syntax. This allows us to create a closure where the inner function retains access to the counter variable even after the outer function has completed execution, as explained in my previous answer. So, in summary, return inner returns a reference to the inner function, which can be stored and invoked later using the fn() syntax, while return inner() would have returned the result of invoking the inner function immediately, which is not what we want in this case.
I want to point out a mistake on 40:10. The Object.create should be before adding new methods. In example above, fightCrime() is the new method, if Object.create is after fightCrime(), that method won't work. You only called getFullName() method in the video so it seems everything works fine. Prototype object cannot be assigned after new methods. All-in-all, great tutorial, keep it up!!
Hello Vishwas! I'm a huge fan of yours You videos are really high quality and you have the skills to explain complex things to others in a very easy way I have learned a lot of things from you Thank you very much for all of this quality content This is better than most of the paid ones as well Hope you get more subscribers soon !
First part was clear, and superb, this video is quite confusing, mostly because of impractical examples which do not represent real scenarios. Must change at least the currying example.
he's clearly saying that this are the fundamentals of those concepts, real scenarios might take a longer video just to cover one of those concepts, this course gives the viewer enough knowledge to go and expand those concepts by themselves, do not expect to learn absolutely everything from a video , btw, you are free to google "real scenarios for currying methods".
I am enjoying watching and learning from this course. I would recommend anyone looking to learn Advanced JavaScript topics. Please watch the prerequisites videos before watching this course. Best of luck everyone. Big thanks to the content creator! You are absolutely wonderful and my best wishes for your wellbeing.
sir i m a beginner ,i watched many tutorials from different sources but the quality and content u give provide has no match....i just stick to learning just bcoz of u sir
When you want to return a function from another function and create a closure, you should return the function itself without invoking it. In other words, you should return inner; (without parentheses) and not inner(); (with parentheses). Returning the function without invoking it allows you to create a closure, which means that the inner function retains access to its containing scope and any variables defined in that scope function outer() { let counter = 0; function inner() { counter++; console.log(counter); } return inner; // Return the inner function without invoking it } const increment = outer(); // Store the inner function in a variable increment(); // This logs "1" increment(); // This logs "2" Without closure function outer() { let counter = 0; function inner() { counter++; console.log(counter); } return inner(); // The inner function is immediately invoked when you return it using return inner(); } outer(); // This logs "1" and returns undefined outer(); // This logs "1" and returns undefined
Great course. There are not many advanced courses that has covered all well-known advanced topics. I am glad i check this one out. Would love to watch if you already have any advanced Nodejs crash course or if we are going to get one soon :)
Something wrong in the closures section your logging the counter 1,2 in console while the function is not returning a value so it is undefined If we add return in the inner function then the value is 0,1 not 1,2
Be careful about difference between writing 'inner' and 'inner()'. As far as i understand, when we wright inner and gave to the fn: we are giving the function itself but not the function's return value. I hope this help.
To undestand closures, just imagine inner function as a normal function in global scope which is outer function. How i get it is like in global scope when you increment something with function it stays to that value and for inner function outer is global scope.
hey Sir, thank you for uploading such a great stuff, I do watch your tutorials, you cleared all my concepts, you are a great teacher, alots of love for you from Pakistan
Checkout my other crash courses!
HTML Crash Course - ruclips.net/video/N8YMl4Ezp4g/видео.html
CSS Crash Course - ruclips.net/video/Icf5D3fEKbM/видео.html
CSS Flexbox Crash Course- ruclips.net/video/z62f2k38s64/видео.html
CSS Grid Crash Course - ruclips.net/video/p4Ith5qRM1g/видео.html
JavaScript Fundamentals Crash Course - ruclips.net/video/XIOLqoPHCJ4/видео.html
Asynchronous JavaScript Crash Course - ruclips.net/video/exBgWAIeIeg/видео.html
Please Make video about react frame motion Thanks ...
Make a ReactNative course too, plz! I mean, in a series!
all courses are crystal clear thankyou
Just 10 mins and the way you explain things is perfect. I've watched countless tutorials before and you really explain awesome.
To the point and no extra useless stuff taught only what is needed. just what i was looking for.
Thank you So much.
In this code, th
e outer function returns a reference to the inner function by using return inner. This is called returning a function as a value, or returning a function reference.
If the outer function had used return inner(), it would have returned the result of invoking the inner function instead of a reference to the function itself. This means that the fn variable would be assigned the value returned by inner(), which is undefined since the inner function does not return anything.
By returning a reference to the inner function, we can assign it to the fn variable and then call it multiple times using the fn() syntax. This allows us to create a closure where the inner function retains access to the counter variable even after the outer function has completed execution, as explained in my previous answer.
So, in summary, return inner returns a reference to the inner function, which can be stored and invoked later using the fn() syntax, while return inner() would have returned the result of invoking the inner function immediately, which is not what we want in this case.
I’d love to watch it now, but it’s 2am and I know I’m going to get brain blasted. Saving for later instead ;)
Same here but it’s 3:28 instead saving for later
Rr
Bet you didn't watch later
I know this feeling.
Same here but it's 01:10am😴 dis side😂
Absolutely awesome. Finally someone who can explain things in the right pace and kept me engaged for whole video.
I want to point out a mistake on 40:10. The Object.create should be before adding new methods. In example above, fightCrime() is the new method, if Object.create is after fightCrime(), that method won't work. You only called getFullName() method in the video so it seems everything works fine. Prototype object cannot be assigned after new methods. All-in-all, great tutorial, keep it up!!
Thank you. I was looking for this solution. 😇
Ok I'm not crazy 😅
Teacher of the year! 🥳 I appreciate that it seems that you know what questions we are going to ask ourselves and you cover every case.
fegasf
Interviewing next week and need a refresher! Thanks for this!
Are you a talent acquisition member?
I love the way you explain difficult concepts in a very simple manner
Hello Vishwas!
I'm a huge fan of yours
You videos are really high quality and you have the skills to explain complex things to others in a very easy way
I have learned a lot of things from you
Thank you very much for all of this quality content
This is better than most of the paid ones as well
Hope you get more subscribers soon !
First part was clear, and superb, this video is quite confusing, mostly because of impractical examples which do not represent real scenarios. Must change at least the currying example.
he's clearly saying that this are the fundamentals of those concepts, real scenarios might take a longer video just to cover one of those concepts, this course gives the viewer enough knowledge to go and expand those concepts by themselves, do not expect to learn absolutely everything from a video , btw, you are free to google "real scenarios for currying methods".
I am enjoying watching and learning from this course. I would recommend anyone looking to learn Advanced JavaScript topics. Please watch the prerequisites videos before watching this course. Best of luck everyone. Big thanks to the content creator! You are absolutely wonderful and my best wishes for your wellbeing.
so it's not aged?, I want to learn but skeptical if this keeps up with the latest js
sir i m a beginner ,i watched many tutorials from different sources but the quality and content u give provide has no match....i just stick to learning just bcoz of u sir
Just watched one hour before an interview..you sir might got me my new job offer
A very nice and clean explanation of difficult concepts in short video. Thanks so much Vishvas. You are great teacher indeed.
Wow best teacher on RUclips for front end.
there are very less resources on design patterns in JS can you please consider one series 🙏🙏🙏
Yes Design Pattern Is One Personally want
@@harshrastogi296 Is one that i personally want*
@@hexadecimalhexadecimal5241 is the one i personally want*
want the same...
@@jim_from_it3261 i was fixing his sentence without changing it mine wasn't wrong tho
My friends think that you talk like a robot, but I like your voice it sounds professional
Thank you very much!
It would get better if you could add more real world examples after each chapters.
Please do a crash course on Dom and async js
When you want to return a function from another function and create a closure, you should return the function itself without invoking it. In other words, you should return inner; (without parentheses) and not inner(); (with parentheses).
Returning the function without invoking it allows you to create a closure, which means that the inner function retains access to its containing scope and any variables defined in that scope
function outer() {
let counter = 0;
function inner() {
counter++;
console.log(counter);
}
return inner; // Return the inner function without invoking it
}
const increment = outer(); // Store the inner function in a variable
increment(); // This logs "1"
increment(); // This logs "2"
Without closure
function outer() {
let counter = 0;
function inner() {
counter++;
console.log(counter);
}
return inner(); // The inner function is immediately invoked when you return it using return inner();
}
outer(); // This logs "1" and returns undefined
outer(); // This logs "1" and returns undefined
Greatest teaching ever. Give this man a Grammy 16:43
In currying example, the innermost function does not return a passed-in function instead it is returning the result of the passed-in function
i really love your teaching style it's awesome
Thank you for this crash course and async js I truly needed them.
Can you make a video on javascript design patterns? It would be very helpful .
people with good English can watch video on 2x for time being, stil you can understand very clearly.
One of the best resources for learning javascript.👍 excellent beginner-friendly examples.
Great course. There are not many advanced courses that has covered all well-known advanced topics. I am glad i check this one out.
Would love to watch if you already have any advanced Nodejs crash course or if we are going to get one soon :)
Amazing tutorial Vishwas. You rock man.
Wow... This is great! Hope to finish this within a month..
thanks teacher. prototype part is the most hard one to understand personally
thank you, sir, I wanted a course like this only
Very nice video, thanks for the explanations!
your tutorials are great
please make tutorials on Remix
This video was really helpful, thank you for the explanations.
And by the way I may have guessed that you are a fan of DC Comics
Awesome course 💫 covered many important topics.
I finally get curried functions! Thank you!!!!
31:19 guy typed "Spermman" as superhero name example. 10/10
Ill watch it later, i love it already
Thanks a lot it refreshes the concepts in very clear way. Great teaching. Thanks Vishvas.
Superb! Great clarity and understanding. Thanks.
I needed to watch this video before my last interview
did u crack the interview
@@saran8287 no )))
Excellent. Onto advance js 😊
12:33 FN parent disease, FN parent disease
Something wrong in the closures section your logging the counter 1,2 in console while the function is not returning a value so it is undefined
If we add return in the inner function then the value is 0,1 not 1,2
Be careful about difference between writing 'inner' and 'inner()'. As far as i understand, when we wright inner and gave to the fn: we are giving the function itself but not the function's return value. I hope this help.
Great thanks
this keyword --> arrow functions should have been mentioned
Thank you so much, you help me a lot!
Thank you so much sir because if you I m learning js
Great video thanks Vishwas
Awesome
Please change editor theme... dark default theme is good to watch videos
Best content by best instructor👍👍
I have noticed you are given an example of the character of the Breaking Bad web series 😂 though I like your react, Js etc tutorials.
Can you please prepare something for Java and Git as well
I didn't properly understood the prototype inheritance part while the class part was simple as I have been doing java and c++
Thanks
Thank you for this tutorial.
I'm at the right place to watch this video💪
A lot of thanks mr.Vishuas
hi viswas sir please start a full fledge gatsby series like your nextjs series we are waiting for your series
This is pretty much awesome
Great job, thanks a lot for your effort :)
it was very helpful thanks a lot now i am waiting for your next crash course on js
Please make a video on async js and include the applications like where we can apply
walter white - you must be fan of BreakingBad.
Thanks for the video
thanks your a good explainer.
Man what the hell im tryna learn about js concepts and boom my man makes a Breaking Bad reference
Thank you so much this is helpful.
dude you rock ❤
WOW thankyou so much
To undestand closures, just imagine inner function as a normal function in global scope which is outer function. How i get it is like in global scope when you increment something with function it stays to that value and for inner function outer is global scope.
Tell me if i am wrong or right
Best refresher again Mr Vishwas, thank You sir :)
Thank you for Breaking JS Badly :)
awesome 💙💙💙
That was a great walkthrough
Very helpful
This was very informative thanks for the info
Thanks Vishwas
Super helpful
Very clear 🙏
hey Sir, thank you for uploading such a great stuff, I do watch your tutorials, you cleared all my concepts, you are a great teacher, alots of love for you from Pakistan
Thanks a lot 💐
Amazing as usual
You're doing god's work. 🔥
Would be nice to also see practical applications. For e.g. in currying, the example was too academic. But very good overall, thanks.
Great class.
Keep up the good work.
Thank You,
Natasha Samuel
Greate content!
I look at the Replay Graph at the bottom and I see so many people went back and watched this Keyword...
I'm scared now...
super cool, thx.
Excellent 💯.
Thank you bro, is gonna be more new videos about JS?
Thank you
thank you!!!
Thank you..!!!
Easy to understand, interesting course to al main content should Finish Interest, Thank you this course, Cover every case 🩷
Great!
video on cypress and jest plz
I said once and I will say again: "Vishvas for President!"
This is still a good tutorial!