Client side JavaScript day 4 part 2 — Transcript
Full transcript
- 0:05What does this do, or what is it called
- 0:08? It adds a bit of what I create in my
- 0:12object. For example, if I have
- 0:15It should be empty. That's it. And we
- 0:19start by telling it here
- 0:24Or that's it.
- 0:26This will start taking the name of the
- 0:28object you want to apply this to. Which
- 0:30is the object. And then here it says you
- 0:32will start putting all the properties
- 0:34you want to define.
- 0:36So we said here, for example, let's put
- 0:37in the properties. So here is the
- 0:38property. And we will start here by
- 0:39opening the object we are passing the
- 0:40property into.
- 0:42The first thing we must add, obviously,
- 0:43is what?
- 0:44My property. Let's say, for example,
- 0:46Mustafa. Okay. And then we said we have
- 0:49one called
- 0:52Let's say now we make it true.
- 0:54And one called enumerable.
- 0:57And one called
- 1:02That's it.
- 1:04For instance, we will also create, say
- 1:12Here is the property, for example.
- 1:16And here is its value 26.
- 1:19So, we said this is responsible for the
- 1:21writable part.
- 1:23That's it. That you modify the value.
- 1:25I mean, if it is currently writable.
- 1:27I can normally, after this line, tell it
- 1:30here the value, for example
- 1:33That's it. And tell it here
- 1:39So, there. If we look, we will find the
- 1:41name is now what? Ahmed. Now, if I go
- 1:43here to the property and tell it, no,
- 1:45your property will be
- 1:47That's it.
- 1:49So that means you locked the property to
- 1:51the one called, so the name will remain
- 1:53Mustafa.
- 1:54You made it exactly as if you did what?
- 1:58You removed it because the property is
- 2:01already, so the name is still what?
- 2:04Mustafa. Alright, I went ahead and
- 2:06grabbed this whole name property and
- 2:08deleted it.
- 2:12So, if we look now at the user, we will
- 2:14find he only has age at what? At 26. Now
- 2:16I want to block anyone from being able
- 2:18to delete any property I have, so we go
- 2:20here to configurable and set it to what
- 2:21?
- 2:22To false or remove it. So, I just
- 2:25deleted the name, but the name is still
- 2:28what? Existing.
- 2:30Now, we said this is responsible for the
- 2:32loop, so if we came here and told it or
- 2:42For the user, it should now, since the
- 2:44property is still true, I will find that
- 2:47I am Looping very normally over the name
- 2:50and the age, but if I remove the
- 2:52property or set it to false, of course,
- 2:54here configurable is also false, we will
- 2:57go and find that it Showed me the age
- 2:59but didn't show me the name because the
- 3:02three values are now false for me, and
- 3:05likewise also Regarding the age part.
- 3:08Now we said we have something that does
- 3:10this data directly for the entire object
- 3:12, something called freeze and something
- 3:13called seal.
- 3:16We said freeze prevents you from—think
- 3:18of it as locking something—you can't add
- 3:20to it nor modify the contents of that
- 3:22thing, but you can see it.
- 3:24So, we are locking the configurable and
- 3:26locking the what?
- 3:29But the enumerable is still working for
- 3:30me normally.
- 3:32Seal is the exact same story but allows
- 3:33you to do what?
- 3:35Meaning it allows you to modify any
- 3:37value.
- 3:38So, these are ready-made values you use
- 3:40for the entire object.
- 3:41Okay?
- 3:43Did I answer your question or?
- 3:46>> Fine.
- 3:46>> Okay, does anyone need us to repeat
- 3:48anything else?
- 3:49Everything okay?
- 3:51Alright.
- 3:59What's the next topic?
- 4:01Okay, does anyone need me to repeat them
- 4:03?
- 4:07Where is the data stored?
- 4:09In the and, always.
- 4:14While the.
- 4:18Let me just double-check a few quick
- 4:19questions.
- 4:58Regardless.
- 5:03Or let's just settle for the first one
- 5:05that comes up.
- 5:09Or.
- 5:11Okay, so why?
- 5:13The is different, okay, the second one.
- 5:28Yes.
- 5:31Anyway, forget the third one, I have the
- 5:32same result.
- 5:44It will return the, the ones I have,
- 5:46right?
- 5:47Why?
- 5:49Because as we said, the first value,
- 5:51since you're comparing between values,
- 5:53it used to return because we were
- 5:54putting in with, so what does it return
- 5:56anyway?
- 5:59Alright, so this will return, okay,
- 6:01which is what? The. Okay, the third one
- 6:03.
- 6:06Or, hmm.
- 6:11We said with the, it always returns the
- 6:13first value, because if one of them is,
- 6:14you don't need to check the rest,
- 6:16because the whole term will return what
- 6:18?
- 6:20Okay, so it will return here, is there
- 6:22any problem with that?
- 6:23Okay.
- 6:26What?
- 6:28This?
- 6:30We said right now, the doesn't need
- 6:32everything to be true to return true,
- 6:34right?
- 6:35Okay, if I find any value, do I need to
- 6:36check the rest?
- 6:38I don't need to, so I return the first
- 6:39value.
- 6:41Okay, if all values are true, I need to
- 6:43make sure they are all true, so I return
- 6:45the last value, what?
- 6:47Okay, and the opposite with the.
- 6:54Alright, so thank God everything is good
- 6:56, does anyone need us to review it again
- 6:59?
- 7:01Hmm, everything okay?
- 7:04Okay, the in a regular function points
- 7:07to whom?
- 7:08And if in.
- 7:12It points to the, it always points to
- 7:15what? To the that it is inside,
- 7:18beautiful, okay, let's go to.
- 7:24Okay, why do I use this? Or what does
- 7:28its look like?
- 7:31Here we start by telling it.
- 7:40And here we write code, and here after.
- 7:44We can here.
- 7:48And here.
- 7:54Okay, so this is the way we write the,
- 7:57what do I use it for?
- 8:00Here we put code.
- 8:05Okay, that it returns what?
- 8:08Returns.
- 8:16>> What?
- 8:21In the, so if you type a word with the
- 8:23wrong spelling, you click here on or and
- 8:26you find it suggesting words for you.
- 8:30Okay, just so the is correct.
- 8:33So when I send you the code, you don't
- 8:34read it in two months and say, "What is
- 8:36this uneducated person?"
- 8:38and it looks bad.
- 8:40Okay.
- 8:41So here we have, in we put code so it
- 8:43returns. Okay. And here in the we do.
- 8:51Okay, my.
- 8:53And the here I have.
- 9:00Okay. Whether in.
- 9:03The case of, okay, it's done.
- 9:10Whether my code had an error or what?
- 9:13So this is exactly the code of what
- 9:15happens. Okay. Okay, now we will take it
- 9:18as a concept. So later, God willing,
- 9:20when we talk about the part of.
- 9:22Or that we are done, you will find that
- 9:25we start using something called.
- 9:28This might return or might not.
- 9:31Okay, so for the shape of this, we start
- 9:32using.
- 9:34Okay, let's take an example.
- 9:36If I came here, for example, and told it
- 9:38.
- 9:41equals 20, for example, okay, and I came
- 9:42here and did the.
- 9:47I came here and told it, if this value
- 9:50is greater than 30, okay.
- 9:58And here, let's write for example, is
- 10:01there any problem?
- 10:04So now I am telling it if this value is
- 10:07greater than 30, okay, start by
- 10:09triggering this error, right?
- 10:11What if I make it 40?
- 10:16So now, what is it supposed to do?
- 10:19And the fact that it did that means the
- 10:21part of the code after it, what?
- 10:23Will not be executed, right? Well, let's
- 10:25see for example, let's say the word.
- 10:29I looked and found that it printed what
- 10:31?
- 10:32The word normally, there was no output
- 10:34at all, why? Because we said we have
- 10:36here, I put any code to be outputted.
- 10:40And here is the form of the error, did
- 10:42we write anything about the error form?
- 10:45No. You can format the error the way you
- 10:47like. You want to output it in an alert
- 10:49, you want to output it in a tag, you
- 10:50want to print it in the console.
- 10:52All this is done through whom?
- 10:54The error, let's take it one by one,
- 10:57here is the error, this error parameter
- 10:59captures what?
- 11:01The error above, or we can dispense with
- 11:03it entirely and start writing the error
- 11:05we started here.
- 11:07Okay, let's write it as we started here
- 11:08, alright? However, because we are using
- 11:10a ready-made one, or it's coming from
- 11:12outside, it's always better to use what
- 11:14?
- 11:15The error of the response, as we can see
- 11:17it outputted the error and sent the word
- 11:19test after it, it didn't stop what?
- 11:21The flow of the code. So let's try to
- 11:24output it in another way, let's say here
- 11:26.
- 11:32So it also outputted it in the form of
- 11:33what?
- 11:35But it still didn't stop the code flow
- 11:37because if it stopped the code flow,
- 11:39anything below it wouldn't be executed,
- 11:41right?
- 11:43Well, I want to print it in the console
- 11:45, here.
- 11:48Currently, God willing, on Sunday we
- 11:49will start to dispense with all this and
- 11:51we will say here.
- 11:55For example, and here we start to
- 11:57display what? Our error.
- 12:06Okay, and here is the error, and we can
- 12:08start saying here.
- 12:13Here we must put the code because I used
- 12:16it, and I will say here.
- 12:20Alright.
- 12:22My error on the page, but if I don't
- 12:25want to output the word error, we said
- 12:28what was my error called?
- 12:31The message, exactly. Okay. So here
- 12:33instead of displaying the whole error. I
- 12:35can say show me only the message here.
- 12:40Okay. So it showed me just the message
- 12:42you wrote inside the error.
- 12:45So the error block puts any code that it
- 12:48outputs.
- 12:49Okay. The error handles the error format
- 12:51in the way that suits you. And it
- 12:52doesn't stop the code flow. The code is
- 12:55executed in both cases. Okay. Here.
- 12:58Okay, whether there is an error or not.
- 13:00Okay. Here is the error, for example.
- 13:05Okay. Let's make this 20, so it won't
- 13:07throw any error.
- 13:09Alright. So it didn't even enter the
- 13:11error phase. Because I didn't have any
- 13:12error or problem. It printed what is
- 13:14found where?
- 13:16And the code that we had already written
- 13:18outside the block, so any code that
- 13:21might throw or is suspected of throwing
- 13:23, we always handle it how?
- 13:27To ensure that I don't stop the flow of
- 13:29the code being executed.
- 13:31That's it.
- 13:32Of course, the process seems easy now.
- 13:34But when we start taking APIs and start
- 13:36fetching data from the API.
- 13:37God knows whether this data will return
- 13:39valid or have issues. Right. So we will
- 13:42start using what?
- 13:44Right.
- 13:47Beautiful.
- 13:50>> Oh engineer.
- 13:52>> It's possible, yes, in the beginning I
- 13:54didn't use it, I only did the catch
- 13:56block at first.
- 13:57>> I mean.
- 14:00>> Good, good.
- 14:02When we deal with the backend, for
- 14:04example, dealing with the DB, so now I
- 14:06want to perform a query.
- 14:10I might enter the parameters incorrectly
- 14:12, so it will throw what?
- 14:14The database error.
- 14:16Okay, if I get an error, I want to close
- 14:18the connection with the server, or at
- 14:21some point, I want to execute code
- 14:23whether it worked or what?
- 14:25Or didn't work. In both cases, close it
- 14:27for me. In Angular, we take something
- 14:29called a connection that stays open
- 14:31between us. Once I've fetched my data,
- 14:33do I need the connection to stay open?
- 14:36No, so where do I close it? In the
- 14:38finally block.
- 14:42Okay, we finished try-catch; let's start
- 14:44talking about callback functions.
- 14:51What is the idea of a callback function
- 14:52? Let's create a function, let's call it
- 14:55, for example.
- 14:59Calculation.
- 15:02This won't take the logic from me, for
- 15:04example, we want to perform an operation
- 15:06, so I need to pass it the operation I
- 15:08will execute, right?
- 15:10And the numbers I will do what with?
- 15:14The operation, let's settle for two
- 15:15numbers, here is the callback, and here
- 15:17are X and Y that we will perform the
- 15:19operation on.
- 15:22And here in my return, I will hold the
- 15:24result of executing the operation.
- 15:28The result of the operation, here it is
- 15:30.
- 15:32So now it will receive the operation and
- 15:35receive the two numbers I'll work with,
- 15:38and its return will be the return of who
- 15:40?
- 15:43The operation.
- 15:49So, if I have.
- 15:54Receive from me here, for example, and
- 15:54here.
- 15:56The operation.
- 15:58And here is.
- 16:05Here.
- 16:07And here.
- 16:15Here.
- 16:17That's it.
- 16:23And here is, for example, if the
- 16:25operation is greater than, so it doesn't
- 16:28give me an error.
- 16:31Here, what about?
- 16:33Is there any problem with that?
- 16:36Well, let's assume the function is in
- 16:38another file; it's not with me now, and
- 16:40I can't call it directly.
- 16:42All my calls will be through whom?
- 16:47This one, which is the only one that can
- 16:50execute it. So if I come here and tell
- 16:52it.
- 16:55It's waiting for what from me?
- 16:58My operation that I will execute, and
- 17:00then the numbers you will execute it on
- 17:02.
- 17:03Let's send it the addition, for example
- 17:05, and the two numbers, say five and ten
- 17:07. Let's see, it executed how much?
- 17:1015. Okay, the same function, I went and
- 17:13passed it here.
- 17:17So it will start subtracting the two
- 17:18numbers, the same.
- 17:22Who is the only one that can call this?
- 17:26The calculation function.
- 17:29And all this, who is the only one that
- 17:31can execute it?
- 17:33The function itself is the only one in
- 17:35control of the execution of the
- 17:37operation.
- 17:39Alright, so this is the same thing we
- 17:41covered, remember, from yesterday?
- 17:56And here we told it okay.
- 18:01And we go up and start telling it.
- 18:07Okay, when I was sending directly, we
- 18:08said that it was what?
- 18:10Executing them, right, in what order?
- 18:13Exactly, but here we were passing
- 18:15something called the, which is
- 18:17considered for me what?
- 18:20Okay, if we did the of the.
- 18:30Okay, and here it has the A and the B
- 18:33and here we tell it the A minus the B,
- 18:36and I came here to the and went.
- 18:42Isn't this the exact same structure we
- 18:44just made above, right?
- 18:46So that is what?
- 18:48Who performs this?
- 18:51Who?
- 18:53It is what controls its, okay, I don't
- 18:56do it, who performs the for it, who?
- 19:00Okay, so consequently, it will start
- 19:02sorting the for me in ascending order,
- 19:03and if you want it descending, you
- 19:05reverse the?
- 19:08The, okay, so let's assume that I have
- 19:10is what, just a second, but I don't know
- 19:13the, so let's take an example, we will
- 19:15take something called.
- 19:21Here we have it has something called, we
- 19:23are dealing with for the first time in
- 19:25our lives, right?
- 19:27Okay, so the here takes from me.
- 19:31Right? Okay, I will perform the for it
- 19:32here.
- 19:38I will perform the here and not look at
- 19:40any, and let's assume we don't know the
- 19:42, I want to know the that I am receiving
- 19:45, it's who?
- 19:49In any, I want to know what the that is
- 19:50coming to me is, who?
- 19:53The, exactly, so here we will start with
- 19:55who?
- 19:57To see what this does and who the that
- 20:00it receives is, right?
- 20:02Okay, let's take a look, but let's just
- 20:05make the numbers a bit smaller so the
- 20:07process isn't too huge, let's say three
- 20:10numbers, we found that it printed my for
- 20:12me how many times?
- 20:15Three times, meaning it prints the with
- 20:17every what? With every number, right?
- 20:20Every number it prints with my.
- 20:25I looked at the, I found it receives
- 20:26from me how many?
- 20:27Or how many, I mean? Three, right? The
- 20:29first is the one, the second thing is
- 20:32its in the which is zero, and then my
- 20:34full.
- 20:35Okay, let's go to the second, we found
- 20:38the second which is two, and its is one
- 20:40, and then the full.
- 20:43The third, the which is four, its is two
- 20:46in the, and here is the, so the inside
- 20:49this receives from me how many?
- 20:53Three, the and the and the, right? Okay
- 20:57, let's verify. Let's go here to the
- 21:00just.
- 21:01We found it printed how many?
- 21:03One, two, and four. Okay, I did here to
- 21:06the.
- 21:09I will find what? Zero, one, two.
- 21:11I did, it will print my what for me?
- 21:14Three times. Okay?
- 21:16So you can, any, inside, okay. And know
- 21:20what the that you are passing to the is
- 21:22.
- 21:23Okay, I have this, I use it to execute a
- 21:26specific on the.
- 21:28Meaning, for example, if I want to
- 21:29perform a, I can do it with the.
- 21:31You don't need to create a and define a
- 21:33variable called. And start telling it i
- 21:36is smaller than the and so on. We can
- 21:39tell it here.
- 21:42Two empty and directly here in the one I
- 21:44know is on all the existing ones, let's
- 21:47start telling it
- 21:50Who?
- 21:52For or for directly.
- 21:55Isn't this the one that grabs it with
- 21:57every loop, is that right? So it starts
- 21:58entering what for me?
- 22:00My directly. Any problem?
- 22:03Does anyone have a question?
- 22:05Okay, what else can we use it for?
- 22:09Ah, we haven't taken the yet, no, leave
- 22:11that for when we go to the for what?
- 22:14To see the shape of the directly. Done?
- 22:16The we have can be used for any you want
- 22:19to apply to the, well let's ask an
- 22:22important question, what is the of this
- 22:25? Didn't we take any and know its?
- 22:28Let's ask quickly, what was its?
- 22:32>> Which is the
- 22:34>> Which is the new, okay, the
- 22:38>> The that I removed, well done, the
- 22:48>> The that was removed
- 22:54What do they return in?
- 22:56In exactly, well done, great.
- 22:58What else from what we took?
- 23:06The
- 23:15>> The new, the new, that's right? Okay.
- 23:18And the
- 23:21>> The new that I merged together. Well
- 23:24done. Great. That's it. The we have, and
- 23:27this question I mean, I will ask it now
- 23:29, I will ask it in the exam, and I will
- 23:32ask it in the, done. There, I told you.
- 23:35Okay.
- 23:37If I came and did for the whole, and
- 23:39came and did for this, done.
- 23:42I will find that it returns
- 23:45The of it always.
- 23:48That's it, the situation is done. Even
- 23:51if we did it ourselves. Meaning if I
- 23:54went inside and did, for example, the
- 23:56word ah. I will still find that its is
- 23:59what?
- 24:02So always my has its done
- 24:06What?
- 24:09Exactly, it has no, because I will have
- 24:11another that returns for me, for example
- 24:13, like the filter and, when we take them
- 24:16in the, God willing, these return, but
- 24:18does not return anything, it executes a
- 24:21specific and that's it.
- 24:23Done, just like the, the grabs something
- 24:26from the, it executes a specific and
- 24:29that's it, okay?
- 24:30Is there any problem with that?
- 24:33So the callback, guys, I use it because
- 24:35there is another that does its or
- 24:37executes its, you just pass it and it
- 24:39what?
- 24:40It works. It runs.
- 24:45We still have another session with the
- 24:47callback tomorrow, God willing, in the
- 24:49when we take something called the, done
- 24:51.
- 24:53Like click for example, when you do a
- 24:54click, you'll find that we pass it and
- 24:56it's the one that executes the, when
- 24:57does it execute it?
- 24:59When the click, and so on.
- 25:01Done?
- 25:02Does anyone have any questions regarding
- 25:03the part of the
- 25:06Is everything okay?
- 25:08Beautiful.
- 25:14So we have the left.
- 25:17We finished very early.
- 25:20Let's talk now about
- 25:27The came to you, man, you're welcome.
- 25:31The we have, guys, is one of the very
- 25:33important things in JavaScript that
- 25:35clarifies many things, for example, you
- 25:37guys, did anyone take
- 25:41Has anyone studied before? You know the
- 25:43, right?
- 25:47You know why the retains the value?
- 25:52So, you’re supposed to, when you change
- 25:55anything in the code, it re-executes
- 25:57everything from the start.
- 26:00So why does it keep the old value?
- 26:03Because of the closures, okay?
- 26:05Now, let's look at what our code
- 26:07consists of; let’s say we have this, for
- 26:09example, let's call it...
- 26:12It’s not difficult, by the way.
- 26:14Alright?
- 26:19Here is the scope of this one, let's say
- 26:22we put a variable here, and here we have
- 26:24another function.
- 26:30Okay, and this second function...
- 26:39Right, this is exactly what it looks
- 26:41like. Let's do this, when we were
- 26:44talking about...
- 26:47We said who sees whom?
- 26:52The inner one sees the outer one, but
- 26:54the outer one doesn't see the inner one
- 26:56. So, can I do this in this case?
- 27:00In this part?
- 27:02Exactly, the inner function or the inner
- 27:05scope can easily see the outer one. Very
- 27:08good. So here, if I said...
- 27:13Okay, if I do this, what will it hold?
- 27:26It holds...we said as long as I hold
- 27:29this, I am holding...
- 27:33What is the returned function exactly?
- 27:36Still, okay? Because I feel like you
- 27:38don't believe me, even though I'm not
- 27:41lying. Here it is, okay. Now I want to
- 27:43execute this, what do I have to do?
- 27:47Run it, right? So in this case, what
- 27:49will it hold?
- 27:51Zero or one?
- 27:53It will hold zero, okay. So here is zero
- 27:56. Now if I did...
- 28:05One. You are holding this, which is what
- 28:07executes it, right? When does it reset
- 28:10to zero? When I run...
- 28:12So it starts to redefine the variable to
- 28:14what? To zero. That’s the trick right
- 28:16there, we’ll get to that later, okay? So
- 28:18here is...One, okay. And every time you
- 28:21increment, it will start incrementing
- 28:24your...Okay, good. I came here and told
- 28:26it...
- 28:32Okay, and I did here...
- 28:37What will it print?
- 28:44What? What’s your explanation, then?
- 29:01Are you recording me, man? Take it and
- 29:03I'll send it to you, and besides, you
- 29:05have the code.
- 29:09Okay.
- 29:13The one that was five, the incoming
- 29:15value should be five.
- 29:16Are we saying it will start from zero or
- 29:17keep it as five?
- 29:21Nice. Okay, very good.
- 29:23Nice, nice.
- 29:24Okay, okay, okay, sure.
- 29:27Normally, as long as I ran this, it
- 29:28should start executing this from the
- 29:30very beginning, right?
- 29:32So as long as we execute from the
- 29:33beginning, what will it do to the value
- 29:35? It will reset it, right? Okay.
- 29:37Let's remember something.
- 29:39Or...
- 29:42Did I, did I change its source or its
- 29:45reference?
- 29:48I didn't change its reference, right?
- 29:50So, this is holding what?
- 29:54Different from whose reference?
- 29:57So, it will continue very normally and
- 29:59output what?
- 30:00Five. When will it print zero?
- 30:10If I did...
- 30:13Because now I am...The old one that I
- 30:15was holding for the function, I removed
- 30:17it and brought a new one with what?
- 30:19Outer...does that mean I...Reset it and
- 30:21I’ll start again from...From the very
- 30:23beginning, okay?
- 30:25So here we have...Zeroing my value, okay
- 30:28? So when something like hooks comes
- 30:30along, it is in this exact form, it
- 30:32keeps the value no matter what you do,
- 30:35the original value inside is still...
- 30:37Preserved because the component function
- 30:39didn't get...From the very beginning.
- 30:41Okay, it is preserved by something
- 30:43called the file.
- 30:44We've been hearing these stories, and
- 30:45until we get to it, we actually have
- 30:47something in Angular called Signals,
- 30:48which is similar to what? useState,
- 30:50right.
- 30:52So, as long as you haven't changed the
- 30:54reference of the main function, or
- 30:55changed its calling, the closure will
- 30:57keep going with me, right?
- 31:00In the closure part. Now, let's start
- 31:02our debugger.
- 31:04To see it step-by-step and observe the
- 31:07closure's scope.
- 31:10Alright, the debugger is running. What's
- 31:13in my scope right now?
- 31:15The global scope. We'll go down a line,
- 31:17fine. It will start entering the outer
- 31:20function, and now the outer function's
- 31:22local scope is there. The 'this' points
- 31:25to the window, and the count value is
- 31:27currently what?
- 31:29It's undefined. Why is it undefined? We
- 31:31are here, guys.
- 31:33Why is the count value currently
- 31:34undefined on this line?
- 31:37Because of what?
- 31:45No, not that.
- 31:48Yes, why then? I mean, before the line
- 31:50executes, why do I know the value of
- 31:52count is undefined? What is that term?
- 31:55What is the name of that term we
- 31:57mentioned? Hoisting, exactly, because of
- 32:00what? Hoisting, right. So, we've done
- 32:02the declaration, now we'll start giving
- 32:04it its initial value, which is what?
- 32:06Zero, right. Now, as we can see, the
- 32:08local scope has also captured the return
- 32:10, which is, for me, what? My function.
- 32:12We went to the next line, it's starting
- 32:14to call the result, it's bringing up
- 32:16whom?
- 32:19The closure, right. The closure is
- 32:20coming from whom? From the outer, and it
- 32:22currently holds the count value of what
- 32:23?
- 32:24Zero. Now we start increasing our count
- 32:27by one. It goes to execute the next
- 32:30function. Our closure's value is
- 32:32currently one.
- 32:34It executes count ++, so its value
- 32:36becomes two, and so on, infinitely,
- 32:38until we reach the point where it's
- 32:40finished.
- 32:43As soon as we finish this line, we go
- 32:44back to the result, and we return to
- 32:46what? The beginning.
- 32:48As soon as we execute it, it will go
- 32:49back to the start and set the count back
- 32:51to what?
- 32:53Currently zero. Then, the next line
- 32:55makes it one.
- 32:57Then it will go and do the result for
- 32:58you from the very beginning, and you'll
- 33:00find the count here is zero, and the
- 33:02next line you'll find it's what?
- 33:05One. So, as long as you haven't changed
- 33:08the reference of the one you're holding
- 33:10, the count will continue normally.
- 33:12As soon as you change the reference, it
- 33:15will start to what?
- 33:16Reset and restart. Your result from the
- 33:18very beginning.
- 33:20Is there any problem with that?
- 33:22Does anyone have any questions?
- 33:25Okay, so the reason it continued after
- 33:28four and printed five here is that I,
- 33:31even while doing the process, didn't
- 33:33change what?
- 33:35The reference of the variable. Of whom?
- 33:37Of the function. You're calling it
- 33:39inside. Is there any problem with that?
- 33:43Is everything clear so far?
- 33:44Does anyone have any questions?
- 33:47Does anyone need us to repeat anything?
- 33:49Alright, looks great.
- 33:55So, we've finished, or covered most of
- 33:57the basics. Of course, there are other
- 34:00things, but we'll talk about them as we
- 34:02go along, like the...
- 34:05And all these things, they are there,
- 34:07but we'll talk about them in the context
- 34:09of our work.
- 34:11Tomorrow, or Sunday, God willing, we
- 34:14will start talking about and dealing
- 34:16with the things inside the [code]. When
- 34:19we were explaining the first day of the
- 34:22[course], we said that we could perform
- 34:25[operations] or [modifications] to the [
- 34:28code]. So here, we will be forced to
- 34:30place our [code] where?
- 34:33Before the [code] closure, or it might
- 34:34be at the top, and I use a specific [
- 34:35tool] with it called [name], which we
- 34:37will talk about in detail tomorrow.
- 34:38We will start taking the [code],
- 34:40modifying what’s inside it, removing,
- 34:42adding—all of this, God willing, we will
- 34:43do tomorrow. All right? And we will have
- 34:46Tuesday left to talk about something
- 34:48called [the topic]. There are also some
- 34:50things related to the [code] itself that
- 34:52we will need to learn along with the [
- 34:54topic].
- 34:56And so on. All right?
- 34:58Does anyone have any questions?
- 35:00Is everything okay?
- 35:02Okay, let's look at the [assignment].
- 35:07Only two tasks today, that's it. Let's
- 35:09just finish the [code].
About this transcript
This page contains the full transcript of Client side JavaScript day 4 part 2 by Negm Courses, generated from the public captions YouTube serves with the video. The transcript has 4,510 words across 764 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.
What you can do with it
Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to choose a caption track available on the video.
Free YouTube transcript tool
YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, caption language selection, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.