Allow One Function Call - Leetcode 2666 - JavaScript 30-Day Challenge

preview_player
Показать описание

Solving day-8 of the leetcode javascript 30-day challenge. Today's topic's include closure and function context, including the this keyword.

0:00 - Understand the problem
1:45 - Solve the problem
4:20 - Function context (this keyword)
8:58 - Proper solution

leetcode 2666

#neetcode #leetcode #python
Рекомендации по теме
Комментарии
Автор

6:20 That's not quite true, "this" isn't undefined here. If it were, you'd get an exception since you'd be trying to access the "name" field on "undefined". In this case, "this" is actually the global object, i.e. "window" when in a browser context. This is also the same object that holds global variables. So the reason you get undefined is because there is no "name" global.

vader
Автор

`fn.apply(this, args)` can be replaced with `fn.apply(null, args)` as for this case we don't actually need to bind the context to any particular object.

I guess LeetCode just used `this` as there needs to be something for the first parameter so `args` can be passed as the second parameter.

FernandoBasso
Автор

Are you guys seeing the syntax highlighting on LC going crazy or is it just me? Getting really annoying 😒😒

BTW my bad if i was moving the cursor too much, still working on that...

NeetCodeIO
Автор

i got solution right after seeing the question, because most often i use in useEffect in react 😆😆

mageshyt
Автор

Day 8 of solving the 30-day challenge with neetcode!

vixguy
Автор

I am a begineer to js and leet code i cant understand the logic of this problems i watched this video quite often times but still i am not clear in the why you have returned the fn.apply(this, age) why you have returned this keyword along with the args

Aashiqui-pfni
Автор

Hello, this video's title is 2666. Allow One Function Call. Am I right?

allenli
Автор

What is this IDE you are using to run JavaScript ?

yashgangrade
Автор

hi sir, i want to reach out to you. please drop your email sir

gangothridarsi