Тёмный

JavaScript Interview Prep: Functions, Closures, Currying 

freeCodeCamp.org
Подписаться 10 млн
Просмотров 138 тыс.
50% 1

Prepare for JavaScript interview questions focusing on closures, functions, and currying. Throughout the course, you'll delve into various aspects of JavaScript, such as function declarations, expressions, scopes, and hoisting, as well as learning about advanced concepts like closures and lexical scope. You'll also gain a deeper understanding of currying and its practical applications in JavaScript.
Course created by ‪@RoadsideCoder‬
Useful Links mentioned in the video -
🎥 var, let and const Video - • Javascript Interview Q...
🎥 map, filter, and reduce Video - • Javascript Interview Q...
🎥 FE Interview Experience Video - • Frontend Interview Exp...
⭐️ Contents ⭐️
⌨️ (0:00:00) Intro
⌨️ (0:01:48) Function Declaration
⌨️ (0:02:13) Function Expression
⌨️ (0:02:34) Anonymous Function
⌨️ (0:03:25) First Class Functions
⌨️ (0:04:54) What is IIFE?
⌨️ (0:06:05) IIFE - Interview Question
⌨️ (0:06:59) Closures
⌨️ (0:07:27) Function Scopes
⌨️ (0:09:10) Function Scope - Interview Question
⌨️ (0:10:18) Hoisting in Functions
⌨️ (0:13:40) Hoisting - Interview Question
⌨️ (0:15:46) Params vs Arguments
⌨️ (0:16:25) Spread vs Rest Operators
⌨️ (0:17:43) Interview Question on params, args, spread, rest
⌨️ (0:19:03) Callback Function
⌨️ (0:20:02) Callback Function - Interview Questions
⌨️ (0:20:58) Arrow Functions
⌨️ (0:21:59) Arrow function vs Normal Function
⌨️ (0:25:13) Closures
⌨️ (0:25:50) What is Lexical Scope?
⌨️ (0:27:39) Lexical Scope - Interview Question
⌨️ (0:28:53) What is Closure?
⌨️ (0:29:44) Example of Closures
⌨️ (0:30:57) Why Closure?
⌨️ (0:32:20) Closure Scope Chain
⌨️ (0:35:13) Ques 1 - What will it print?
⌨️ (0:37:10) Ques 2 - Write a function for this
⌨️ (0:39:29) Ques 3 - Time Optimisation with Closures
⌨️ (0:42:08) Ques 4 - setTimeout + block scope with Closures
⌨️ (0:47:08) Ques 5 - Create a private counter
⌨️ (0:49:49) Ques 6 - What is Module Pattern?
⌨️ (0:51:40) Ques 7 - Make this run only once
⌨️ (0:54:18) Ques 8 - Once Polyfill Implementation
⌨️ (0:58:11) Ques 9 - Memoise/Caching Implementation
⌨️ (1:03:46) Ques 10 - Closure vs Scope
⌨️ (1:04:25) Currying
⌨️ (1:04:55) What is Curring in Javascript?
⌨️ (1:05:23) Example of Currying
⌨️ (1:08:17) Ques 1 - Implement sum(2)(6)(1)
⌨️ (1:11:02) Ques 2 - Reusing Variable for logic
⌨️ (1:14:09) Ques 3 - Infinite Currying
⌨️ (1:18:27) Ques 4 - Currying vs Partial Application
⌨️ (1:20:37) Ques 5 - Manipulating DOM
⌨️ (1:23:01) Ques 6 - curry() implementation

Опубликовано:

 

20 июл 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 109   
@pranavbhat29
@pranavbhat29 Год назад
1:25:42 - I almost spent 10 minutes trying to figure out why he is using func.length >= args.length, only to realise a few seconds later he fixed the bug. Typically viewers might be actively thinking as you speak and such bugs can cause confusions, so I would humbly request processing the video beforehand to avoid such confusions.
@iuhere
@iuhere Год назад
I do like the way you explained it, and tried to keep the code simple and minimalistic to avoid confusion. This especially helps when you are exploring a complex concept. Apart from once function I was almost able to understand all, also in one go with small breaks,so the video was interesting enough to keep me attentive including some minor drink and stretch breaks. This is indeed a great valued content worth every single second of my watchtime but hey, we don't count in seconds , right? :) TLDR : Great content. Good luck for future ones, and this one helped a lot.
@abhishekmohanty232
@abhishekmohanty232 9 месяцев назад
Thanks a lot man, I had watched this video a day before my interview and some of the interview questions were exactly the same , and I was able to successfully clear the interview in a really good product based company 😊
@samfisher8583
@samfisher8583 9 месяцев назад
Were you hired?
@abhishekmohanty232
@abhishekmohanty232 9 месяцев назад
Yes😊
@bablugupta2119
@bablugupta2119 7 месяцев назад
which company brother?@@abhishekmohanty232
@j2devstudio
@j2devstudio 3 месяца назад
Piyush I found this video when I had 24 hours to prepare for a technical interview to test javascript proficiency. I have to tell you how much I appreciate your interview prep video because it seems I had forgotten many things. Honestly, some topics were never made so clear for me - you're a great teacher. I'll follow up here once I finish the interview, but I definitely owe you a coffee ! thank you
@solaraproject3614
@solaraproject3614 9 месяцев назад
Here is an alternate explanation for "setTimeout + blockscope": "a" contains a for loop that iterates three times. Inside the loop, a setTimeout function is called for each iteration, with a delay that increases with each iteration (0, 1000, 2000 milliseconds). However, the callback function inside the setTimeout refers to the variable i, which is declared using var. Since var does not have block scope, the final value of i after the loop completes is 3.
@divinesovereign3103
@divinesovereign3103 6 месяцев назад
such an amazing content thank you so much! - a guy from the Philippines.
@mayursmahajan
@mayursmahajan 10 месяцев назад
Bro literally saved my life today, I watched this video before the interview, It went excellent.
@Antonailzb
@Antonailzb 6 месяцев назад
did you get the job?
@mayursmahajan
@mayursmahajan 6 месяцев назад
@@Antonailzb Yes bro, I started 3 months ago here.
@Antonailzb
@Antonailzb 6 месяцев назад
@@mayursmahajan congrats bro! hope its been good to you
@WinchesterD
@WinchesterD 4 месяца назад
Great course, from basic to advanced questions.
@hanius5438
@hanius5438 2 месяца назад
This is such a good prep, but also entertaining somehow, first time watching stuff like this.
@lucien5112
@lucien5112 Год назад
Another solution for ques 6 at 1:23:01 -> "const curry = f => a => b => c => f(a, b, c)" expanded code for clarity function curry (f) { function layer1(a){ function layer2(b){ function layer3(c) { return f(a, b, c) } return layer3 } return layer2 } return layer1 }
@zzh315
@zzh315 Год назад
the manipulating DOM example does not seem to be of using currying, but more of using closure to store value of id.
@lavish532
@lavish532 Год назад
absolutely best timing, I have an interview tomorrow. thanks FCC !
@lihonghan324
@lihonghan324 Год назад
41:01 Both approaches should give almost constant value (the first approach is longer and the closure one is short). There is no async involved in the process, and we will run the large for loop either way no matter what is the input value. The reason closure is faster is not because there is any magic in it, but just you run the closure() before the counting and it is like a cache, storing the calculated array in the function scope. Let me know if my understanding is correct, otherwise, it does not make sense to me
@ujjwaldixit9777
@ujjwaldixit9777 Год назад
You are correct. The optimization comes into play when you need to call the anonymous() function multiple times with different indices. Without memoization, each call to find() would recompute the entire array on every invocation, resulting in significant overhead. By using memoization, you ensure that the array is computed only once and subsequent calls utilize the precomputed array, reducing redundant computations and improving performance.
@kvelez
@kvelez 6 месяцев назад
Excellent course, great video.
@user-vb6gd7ug1w
@user-vb6gd7ug1w Год назад
תודה!
@user-hw4td5zc1g
@user-hw4td5zc1g Год назад
i like the methods using shorthand syntax its like making your naming of functions more reusable
@natali_li90
@natali_li90 Год назад
Thank you so much for this video! Waiting for "this" video 😉
@RoadsideCoder
@RoadsideCoder Год назад
Thanks, You can check that video here - ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-rv7Q11KWmKU.html
@Mohammedrabeeh-fg1ww
@Mohammedrabeeh-fg1ww Год назад
@@RoadsideCoder 👍👍
@sudhirkalivarapu97
@sudhirkalivarapu97 Год назад
Can a value can be shared between sibling functions in a function in closures
@genacator
@genacator Год назад
Love the part on closures.
@elias-soykat
@elias-soykat Год назад
41:01 I still not using closure but i get the same performance boost :) function find(index) { let a = []; for (let i = 0; i < 10000000; i++) { a[i] = i * i; } console.log(a[index]); return function () {}; } const closure = find(12); console.time("12"); closure(); console.timeEnd("12");
@sumeyyea
@sumeyyea Год назад
that's what i was waiting for 🏆 plss release more videos related to interview
@suplays
@suplays Год назад
Im already subscribed to his channel and love his content. ❤
@aguarosada5
@aguarosada5 Год назад
thanks for this content will help me !
@yabuking84
@yabuking84 8 месяцев назад
57:57 i though using apply() on arrow functions doesnt affect it?
@rashim
@rashim Месяц назад
17:30 Its Rest *Parameter* and Spread *Operator*
@teslavlogs8568
@teslavlogs8568 Год назад
Awesome 👏
@ManishKumar-ud6kj
@ManishKumar-ud6kj Год назад
🎉 nice
@mrdarkdayy9902
@mrdarkdayy9902 Год назад
You know the tutorial is going to be superior than others when the guy is Indian.
@ichiroutakashima4503
@ichiroutakashima4503 Год назад
Was I simply too afraid? Should I start applying? Are these really expected interview questions for entry level?
@euroclydon7883
@euroclydon7883 Год назад
Roadside coder is here🔥🔥
@AbhituklVerse
@AbhituklVerse Год назад
Explain?
@sky_9460
@sky_9460 4 месяца назад
his channel name @@AbhituklVerse
@cendolbang99
@cendolbang99 Год назад
this closure thingy is huge stuff I just discovered today, thank you!
@Imran_kpk
@Imran_kpk Год назад
Great❤
@GAGANDEEPSINGH-fv2rt
@GAGANDEEPSINGH-fv2rt Год назад
This questions is very good for entry level js coding interview
@pranavbhat29
@pranavbhat29 Год назад
41:01 - Should it not take the same time in the non optimised implementation because the loop would run the same number of times irrespective of the index passed?
@lihonghan324
@lihonghan324 Год назад
have the same question, no idea why the time is different
@kuubeu
@kuubeu Год назад
the loop runs when the function is assigned (`const closure = find()`) - the variable `a` is then stored inside the newly created local scope and calling `closure(n)` only needs to read the value from the precomputed array
@pranavbhat29
@pranavbhat29 Год назад
@@kuubeu You did not understand the question which I asked, never mind. The non-optimized was not optimal because there was no precomputation, and hence in every invocation the array was created again and again, and that would be time-consuming. And optimizing in this context meant pre-computing so that the time to construct the array, again and again, is saved. However, if you do notice the code carefully in both versions, the size of the constructed array is the same ( 1000000 or 1 million ) and hence the time taken to construct the array should be the same theoretically be it in an optimal and sub-optimal version.
@kuubeu
@kuubeu Год назад
@@pranavbhat29 it does take the same amount of time if you run it only once, after that it's basically instant: unoptimized: find(a) // takes long find(b) // also takes long // ... all slow optimized: const closure = find() // takes long closure(a) // very fast closure(b) // very fast // ... all fast
@pranavbhat29
@pranavbhat29 Год назад
@@kuubeu In the video unoptimized: find(a) // takes t1 milliseconds find(b) // takes t2 milliseconds // and t1
@monotroupe6294
@monotroupe6294 Год назад
Java interview prep next😊
@narinkotsuwan
@narinkotsuwan Год назад
สวัสดีค่ะขอบคุณค่ะ❤😂🎉😢😮😅😊
@madhousenetwork
@madhousenetwork Год назад
Came in good time
@joshc2368
@joshc2368 Год назад
Definitely needed this
@Khadi-C
@Khadi-C Год назад
Thanks for this! I'm saving this for when I'm ready for interviews.
@alexanderkomanov4151
@alexanderkomanov4151 Год назад
Thanks!
@sushantkunkekar2155
@sushantkunkekar2155 Год назад
Life saviour
@worldbest3097
@worldbest3097 Год назад
awesome!1
@nick-pu4zae
@nick-pu4zae Год назад
@ivailonetzov6662
@ivailonetzov6662 Год назад
Do a java job prep
@user-hw4td5zc1g
@user-hw4td5zc1g Год назад
the infinite currying is like recursion
@tejasukalkar2199
@tejasukalkar2199 Год назад
I've interview tomorrow and this video came as blessing in disguise for me thank you @freecodecamp😊😊❤❤
@dhiyanabdurazack5257
@dhiyanabdurazack5257 Год назад
I will pray for you to get the job when I sleep and when I am in the bus 🚌. Good Luck. i am going to travel in a 6 hours trip by bus with my mother to meet my sister and brother because of eid.
@About-world1777
@About-world1777 Год назад
Did you pass your interview
@629_nishantghadigaonkar3
@629_nishantghadigaonkar3 11 месяцев назад
Can you tell me about your interview experience?
@abcproduction6819
@abcproduction6819 9 месяцев назад
He failed miserably … nobody learn coding by watch RU-vid videos
@tejasukalkar2199
@tejasukalkar2199 9 месяцев назад
@@abcproduction6819 No I didn't
@k4nful
@k4nful 9 месяцев назад
35:24 is so confusing because on hoisting 14:26 with var the behavior is not the same...
@annalan1895
@annalan1895 Год назад
Could I cooperate with you on promotional video about software? Thanks
@NoHorizon-
@NoHorizon- Год назад
How did he move square() to console log? I mean what is she shortcut?
@ayaanshaikh6374
@ayaanshaikh6374 Год назад
That's called a cut in the video, my guy
@hrvojematosevic8769
@hrvojematosevic8769 9 месяцев назад
You can cut the code by using keyboard shortcut ctrl + x, ctrl + v or use VS code shortcut by selecting text, holding alt key then moving it up and down with arrow keys.
@songs123d
@songs123d 4 месяца назад
Treasure content.
@yashvanthkumar2576
@yashvanthkumar2576 7 месяцев назад
Some one explain how this is working function once(func, context) { let ran; return function() { if(func) { ran = func.apply(context || this, arguments) console.log("ssss", ran) func = null } return ran } } what does ran contains after running and how the function reinitialized to null?
@manikmahajan2603
@manikmahajan2603 6 месяцев назад
- Depends on the return value of the func. As per the example in the video, func is console.log and returns undefined. So, ran will have a value of undefined. When the inner anonymous function is called for the first time, func is assigned a value of null. Then after that when anonymous function is called again, func will value null. So, it will not enter the if block.
@Argylleagen
@Argylleagen 3 месяца назад
20:00 🔖
@billycris2878
@billycris2878 Год назад
I understood nothing
@criminalsnail757
@criminalsnail757 Год назад
Can someone explain 9:10?
@RoadsideCoder
@RoadsideCoder Год назад
To understand that better, you need to understand scope of var, let and const. Just watch my var,let,const video!
@forheuristiclifeksh7836
@forheuristiclifeksh7836 16 дней назад
16:24
@aimeneharbi3913
@aimeneharbi3913 Год назад
We need dart language
@JOJO_THE_PROGRAMMER
@JOJO_THE_PROGRAMMER 3 месяца назад
47:45
@princess_maya_
@princess_maya_ Год назад
There's a joke somewhere to be made here about currying lol
@forheuristiclifeksh7836
@forheuristiclifeksh7836 16 дней назад
1:23:00
@ayushraj-fq4gn
@ayushraj-fq4gn Год назад
you were always referring to another video for another concept this video could have been good if all concepts were clear at the same time
@official_ashhh
@official_ashhh Год назад
Referenceerror: function not working
@official_ashhh
@official_ashhh Год назад
ReferenceError: argument is not valid
@official_ashhh
@official_ashhh Год назад
defined*
@govindbisen388
@govindbisen388 9 месяцев назад
Pdf de do
@jomareperocho
@jomareperocho Год назад
CURRYing
@arkansavalder
@arkansavalder Месяц назад
Racist
@impulseimp1035
@impulseimp1035 Год назад
Dond dell me whad uoo duooo please 😅
@wb4529
@wb4529 Год назад
hehe
@aammssaamm
@aammssaamm Год назад
Why do you need to yell? Do you think we are deaf?
@watchtube9429
@watchtube9429 Год назад
hahahahahahahahaahahahahahahahaahahahahahahahahaahahahah
@rba1aji216
@rba1aji216 Год назад
bruh
@m_yoda
@m_yoda 8 месяцев назад
too much ads, every 3 minutes he advertised his product.
@RoadsideCoder
@RoadsideCoder 7 месяцев назад
which product?
@josephlee4001
@josephlee4001 Год назад
The stock market's dividends motivated me to start investing. What counts, in my opinion, is that you will be able to live off of dividends without selling if you invest and make more money in addition to payouts. It suggests that you can give your children that advantage, giving them a head start in life. I've invested more than $600k throughout the years in dividend stocks; I'm still buying more today and will keep doing so until the price drops even further.
@johnrobert4538
@johnrobert4538 Год назад
It's always inspiring to hear from a veteran investor who has weathered the storm and come out on top. When your portfolio turns from green to red, it might be unsettling, but if you have invested in great companies, you should just keep adding to them and stick with your plan.
@bendickson9414
@bendickson9414 Год назад
I wholeheartedly concur, which is why I appreciate giving an investment coach the power of decision-making. Given their specialized expertise and education, as well as the fact that each and every one of their skills is centered on harnessing risk for its asymmetrical potential and controlling it as a buffer against certain unfavorable developments, it is practically impossible for them to underperform. I have made over 1.5 million dollars working with an investment coach for more than two years.
@bendickson9414
@bendickson9414 Год назад
There are many financial coaches who excel in their profession, but for the time being, I employ "Jackson Sten Marsh," because I adore his methods. You can make research and find out more.
@blogactivities5462
@blogactivities5462 3 месяца назад
this video leads new programmers to terrible mistakes / I do not recommend
@Argylleagen
@Argylleagen 3 месяца назад
Could you elaborate on that?
@arkansavalder
@arkansavalder Месяц назад
Internal Pointerrrr variable
@narinkotsuwan
@narinkotsuwan Год назад
สวัสดีค่ะขอบคุณค่ะ❤😂🎉😢😮😅😊
@bishalmahanta1765
@bishalmahanta1765 Год назад
25:19
Далее
Javascript Interview Prep Course 2022
1:02:33
Просмотров 69 тыс.
Learn Closures In 13 Minutes
13:22
Просмотров 47 тыс.
АРЕХ ПОЙМАЛ БЕЛКУ ОТ ИГРЫ ВП
15:01
5 Design Patterns That Are ACTUALLY Used By Developers
9:27
How to NOT Fail a Technical Interview
8:26
Просмотров 1,3 млн
5 Essential JavaScript Interview Questions
20:32
Просмотров 90 тыс.
JavaScript Interview questions everyone gets wrong
6:40
Top 100 JavaScript Interview Questions and Answers
3:00:42