Recursion - Javascript In Depth

preview_player
Показать описание
We take a look at recursion and how we can implement it in Javascript together. Recursion allows us to call the function we are in from within itself and setup cases where we can break out of the "recursive loop". We see some cases where we need recursion to solve certain types of problems that would be a struggle with constructs like loops or functions.

We go through a few "simpler" examples followed by a more complex but realistic example of recursion over a tree-like data structure (a gold mine). We use this to walk through different mine configurations and trace the code line by line to see what is happening inside the recursive loop.

Note that this is an advanced topic and will take a lot of practice and trying different things over time to really cement. We'll go through some practice exercises together on recursion in the next video in the series.

Chapters:
00:00 Introduction
02:18 Why Recursion?
05:55 Functions in Functions?
08:48 Intro Recursion Code Example
15:14 Recursion Array Example
27:16 Recursion Return Visuals
29:25 Recursion Gold Mine Adventure - Trees
31:06 Gold Mine Level Design and Goals
32:36 Gold Mine 4 Level Layouts
34:09 Possible Mine Layouts
37:25 Walkthrough 1 Level
38:21 Walkthrough 2 Levels (One side)
41:34 Walkthrough 2 Levels (Both sides)
43:55 Practice Example 3 Levels
44:05 Possible Algorithm
47:20 Coding the Gold Mind Recursion
57:05 Code Walkthrough
1:02:21 Advice to Learn and Practice
1:05:51 Next Steps

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

This is literal gold mine. Pun-in-ten-dead

ShivamSharma-dqpu
Автор

This is an excellent video. i have been watching a few of your videos. i absolutely love them. i love the interviews and even wish you had more on your channel.
i love the way you explain all of the concepts in your videos.
i hope you keep making content because you're a brilliant teacher.
thanks

matt-yfnz
Автор

Thank you very much for the cristal clear explanation about this topic!
I'm still a fresh student (since the last 3weeks) on JS and I really understood all the presented concepts.
For the last code, at a first glance I didn't quite understood why you didn't use else after the first. On the code walkthrough it just hit me... we need to enforce going into the if (right) every time since there can be a left inside a right (if I can make myself clear here) :)
Keep up the good work and thanks for being here teaching, definitely worth the watch, like, subscribe, share, ...

tiagocastro
Автор

this was the most interesting topic so far

jjjj
Автор

Awesome series nader, what role are you currently in?

sunnyarora
Автор

Solid video Nader. I was going to start the Closure video, but you mentioned this video at the start of that video, so I wanted to do this first, and glad I did.
I always knew about recursion, maybe not by name, but never really understood it. With your mine and tree analogy in this video, now I know where it can be super useful, and have a great understanding of it all.

Thank you very much, I really appreciate it. 😄

sixfortyfour
Автор

straight brilliant. at first i wa slike 1 hour + video dodge.. but then you engaged me with the example of the goldmine wow.

alexgalal
Автор

After you've finished the JS Course, do you pretend to start a React one too??

bertoldoklingerdev