I just gave my interview and in this interview they asked me about closures. which ofcourse i have no idea. I have used it but no idea what is called. and i open my youtube and boom you are there. really like the simple explaination.
@anothermouth7077
21 күн бұрын
Those know-it-all interviewers always play with these gotcha questions which are not even practical anymore
@looming_
21 күн бұрын
@@anothermouth7077closures are pretty important tho
@thecoolnewsguy
21 күн бұрын
Such useless interview questions. They really need to ask about the job instead of stupid shit that you're not gonna use 95% of the time
@jessecalato4677
20 күн бұрын
@thecoolnewsguy you will use closures constantly though, and terminology is important for proper communication...
@thecoolnewsguy
20 күн бұрын
@@jessecalato4677 I know. Yes closures are used extensively but asking about the var gotcha in a loop is just stupid like who's gonna use var in 2024 for a new code?
@matheusneves688
20 күн бұрын
Thank you! Amazing content!
@PavloBozhok
20 күн бұрын
Thanks a lot, I know and remember how closure works in javascript, but I never knew about something tricks.
@jovi9918
21 күн бұрын
Great quick watch
@mewansynniang1902
8 күн бұрын
Beautifully explained
@xzex2609
21 күн бұрын
React vue and angular use closures all the time , all functional components are closures
@maciejzettt
19 күн бұрын
As well as state management is
@Regeneration1996
15 күн бұрын
And react hooks to 😅
@xzex2609
15 күн бұрын
@@Regeneration1996 of course in the end a hook will return some functions as objects and states too , when I was said react I mean most of it uses closures
@TalesGrechi
21 күн бұрын
Great video!
@RaimundoAraujoCorrea
18 күн бұрын
I use one type closure all the time, combined with promises, when I have to execute a function on an array of data asynchronously, all you have to do is return a promise with a function, inside create a couter at 0, create the function thats going to process an entry, before return, incremente the counter, and excecute the inner function again, when its done, resolve the promise.
@blueghost512
21 күн бұрын
Best used in Factory design pattern.
@tommysmith5479
20 күн бұрын
So, if I can sum up and get confirmation: a closure is where an outer function or scope is not garbage collected because there is an inner function that relies on the outer function or scope's variables... is this correct?
@karimkrimou399
21 күн бұрын
Excellent and really clear approch and explantion
@ironCheval
21 күн бұрын
Does it keep the dependant variable and delete the old ones? E.x. when you added age = 30, will age = 29 be kept still by javascript?
@MbzMOKKA
21 күн бұрын
No because it's the same memory spot. In his example, when he does age = 30, it overwrites the value 29 in variable 'age', instead of creating a new variable.
@doniaelfouly4142
18 күн бұрын
Thanks
@crakyanime8903
20 күн бұрын
it would be good if you cover conditional scope or conditional closures
@saurabhshrivastava5383
6 күн бұрын
Hello Kayal, In your second example for closuers "function elementCreator(element)", if we directly return document.createElement(element) instead returning a function then what difference will it make, I think direct return will be better, what you suggest.
@captkalik
13 күн бұрын
That for loop let var closure interview question is just brutal
@lesalmin
21 күн бұрын
This is the best explanation of closures I've seen (including your own previous explanations).
@manpreetjord1885
19 күн бұрын
Great video as usual. But Kyle, your 1x Playback speed feels like 1.25x bro. 🙂 Interviewers also ask that how you will print 0,1,2 when using var i=0; . We have to use the concept of closure here.
@Kingreey
2 күн бұрын
Excelent
@QuanTran-wt4yt
21 күн бұрын
Can you make a video talking about message queue?
@alexandraweather4156
19 күн бұрын
Thank you for this video and the job you do, but what is a JavaScript Developer? The only thing i could find is "JS developer" - in react, angular, vue and stuff Is there atually a job for JS developer in JS?
@dfields9511
21 күн бұрын
Pascal lets you do this as a well, never used that feature of pascal. But was forced to Learn it
@siasquad7360
21 күн бұрын
Sir please explain with the help of draw and after that code
@plamenyordanov131
11 күн бұрын
Printing 3 times 3 has more to do with the event loop than closures
@Mari_Selalu_Berbuat_Kebaikan
20 күн бұрын
Let's always do alot of good ❤
@iftekharhaidar2397
21 күн бұрын
Dear, could you please explain what is JavaScript reference memory?
@consoledoterror971
21 күн бұрын
I think the explanation for var, let with for loop is a bit wrong. 🤔
@amiryankolovich8560
20 күн бұрын
I ran the code with the var and got 0,1,2 🤔
@amiryankolovich8560
20 күн бұрын
Oh its because i had an error few lines before this I guess its js weird engine
@24306529
18 күн бұрын
dude be selling 10 other videos within 1 video
@mcRidersEvolution
21 күн бұрын
What is the purpose of returning function which returns element and not returning element with the first function?
@sealsharp
21 күн бұрын
I was just wondering, is it possible to see the what structures&code JavaScript actually creates? Don't know how to call it. In C#, you can see the different stages ( C#, IL, ASM ) and that makes perfectly clear how closures technically work.
@letsbeafraid2233
21 күн бұрын
JavaScript doesn't create code it gets JIT compiled into machine code directly by the engine. Read about V8 and how it works
@ajiteshmishra0005
20 күн бұрын
Hii brother... You explained let and var concept in for loop. But still I'm confused. Can you explain in some other way.
@AlThePal78
21 күн бұрын
I honestly thought that it didn't call function too until it said return function to and since the variable was already age 30, that is why it started with 30. What if you called the function first?
Unrelated but why are you running VS Code as Admin? 🤔
@himalayagupta7744
16 күн бұрын
I had doubts for this last example, so I asked gpt to explain it to me deeply. It errored the first few times but at last gave the correct answer which claude also verified. Yes, for each iteration of the loop, a new scope is created, and within that scope, a new binding for the variable i is created. Here’s a detailed breakdown: First Iteration (i = 0): A new scope is created. A new binding for i is created and initialized to 0. The setTimeout callback captures this binding, so it logs 0. Second Iteration (i = 1): A new scope is created. A new binding for i is created and initialized to 1. The setTimeout callback captures this binding, so it logs 1. Third Iteration (i = 2): A new scope is created. A new binding for i is created and initialized to 2. The setTimeout callback captures this binding, so it logs 2. In each iteration, the let declaration ensures that i is re-declared and re-initialized within the new scope. This results in three separate bindings for i, each one unique to its iteration.
@johnpatrickoldfield534
20 күн бұрын
Do you know how to do that integer story with a public bank website inside a private login inside page two with a currency and interger value where I need to insert a legal agreement account balance update from 0 => R 1 000 000 Zar ? It’s a public https web address?! The javascript wipes the direct insert after page refresh how do I make the interger value const? Do you have team viewer and want to try and or show me?
@JacobZigenis
20 күн бұрын
Hate to break it to you, but absolutely no one is going to help you with manipulating a bank website. Further, what you're seeing isn't just javascript wiping the value. It's retrieving the value from the bank's servers, which you cannot modify no matter how much you manipulate the page. Gotta study up a lot more and stop asking for advice on malicious activities on KZitem. Also, on the off chance you do manage to do something malicious, you will almost certainly get caught.
@johnpatrickoldfield534
20 күн бұрын
@@JacobZigenis my laptops storage is full and not booting at the moment so I cannot screenshare. I don't see how it's my problem the external and Internal banking staff cannot manually show me howto insert credits into bank tables in cobol or whatever the language is from the email pseudocode to the browser web security layers in the osi model so that I may make debits to pay attorney legal fees for bank account topups. I think it's worth a trial investigation ie look, screenshare, record discuss, etc and a look into the file and code framework on the Javascript and in the console just for a deeper explination, because I just know sql server, table updates, hidden servers, html, Javascript and css. The actual coding language and topology to see exactly where the update changes are made. Worse case the system gets reported and then gets fixed. I don't think it's too complicated less than 1000 lines of code plus minus with like 400 lines on my screen at once with like 30 lines each side of the zero balance variable.
@viallymboma9874
15 күн бұрын
In fact the concept of react custom hooks relies on the notion of closure When you're building a react custom hook, you're actually using closure.
@green-coder-clj
21 күн бұрын
I misread the title as "Learn Clojure in 13 minutes" 😅 Clojure & Clojurescript indeed help landing a job for the FE.
@user-ik7rp8qz5g
19 күн бұрын
What you describe is just oop, but with extra steps
@DanielBrownsan
8 күн бұрын
I genuinely thought I had the playback speed set to 150-200% for the first 3 minutes of the video.
@alienews0
11 күн бұрын
<a href="#" class="seekto" data-time="300">5:00</a> nope u didn't called your function on that line, u declared it ; u called it on the last line : return func2
@MichaelKire
21 күн бұрын
Fun fact. Classes in JS is actually just syntactic sugar for a closure with a special constructor/prototype function inside
@charleschukwuemeka8482
21 күн бұрын
While watching the video, this came to my mind... It's nice seeing that someone else thought of the same thing
@trombecher
21 күн бұрын
A class is syntactic sugar for a function, not necessarily a closure. A function becomes a closure when capturing variables from the parent scope, not because it’s a class.
@aqibmalik6313
21 күн бұрын
first comment after first comment of arunkaiser😂😂
@jovincebrillantes1042
20 күн бұрын
So they're called closures, well I'll be dammed. I've been calling them higher order functions all this time.
@rico454
19 күн бұрын
They are kinda the same thing. Higher order functions return a function and usually, the function that is returned has access to variables inside the original function which is what closures is. So yeah different concepts but essentially the same thing
@Efecretion
21 күн бұрын
Closure to scoping is like 0/1 to binary -- closure is how scoping is implemented in JS, while 0/1 is how binary is represented typically.
@BMikel
21 күн бұрын
Please create Next js e-commerce project catalog with multiple checkboxes filtering, sorting, pagination, search. More e-commerce realistic. Thank you.
@bobwilkinsonguitar6142
21 күн бұрын
I think you should do it!
@arunkaiser
21 күн бұрын
First comment
@aniketroy03
21 күн бұрын
autograph pls 😂
@Pacvalham
21 күн бұрын
🥇
@trombecher
21 күн бұрын
If you have a global function that captures a variable from the outer (global) scope, then this function is a closure, because a closure is a function that captures variables from the parent scope. Even if you are calling console.log, because console is a variable in the global scope, you are capturing a variable and therefore your function is a closure. The only functions in JavaScript that are not closures are pure functions. Please do some research before making a 13min video about a topic.
@looming_
21 күн бұрын
Really makes me wanna buy his “course” xd
@alpaca_growing_kit
21 күн бұрын
If you work with React you desperately need to understand closures. I have run into some insane React bugs that were created because of closures in complex functional React.
@alpaca_growing_kit
21 күн бұрын
HINT: Watch out for modifying an onChange when its getting prop drilled. Another reason to create context hooks as often as possible...
@looming_
21 күн бұрын
Fact that this dude didn’t mention react once makes me question his understanding. Also the fact he messed up the for loop example.
@jasonsworld333
21 күн бұрын
Too bad the jobs are all taken lol
@anothermouth7077
21 күн бұрын
In Same boat 😂
@AchwaqKhalid
21 күн бұрын
Dude increase your *FONT* size for tutorials at least 💡
@manit77
17 күн бұрын
This is not true for all programming languages. JavaScript is an anomaly.
@zfolwick
15 күн бұрын
god I hate javascript
@b1studio648
15 күн бұрын
Why u move ur head too much? Can you hold your head still while recording or move less. I would appreciate it. The way u move your head makes me dizzy
@logimw
17 күн бұрын
why your head bouncing so much? it's very disracting no matter how valuable content you show (always very valuable)
Пікірлер