Now that you have the basics of JavaScript and working with JavaScript in the web down, we wanted to revisit some fundamental concepts and give you a deeper understanding of how to use them effectively in your programs.
These exercises will take a closer look at functions in JavaScript.
- Using Visual Studio Code, open the folder
flexpath-revisit-functions-exercises
wherever you saved it on your device. - Then open the
flexpath-revisit-functions-exercises/exercise
folder. Inside are a collection of folders for each exercise. Exercise instructions are provided to you in .txt files in these folders. - To test your code, you will open up your terminal, and navigate to the specific
exercise_[number]
folder inside of the largerexercises/
folder where you are working in, using the change directory commandcd
. - You will then run the command
node [filename].js
to run whichever file in the folder you are working with, replacing[filename]
in the command with the file's actual name.
Exercise solutions are in the /solution
folder
We have also included a list of challenge problems for you to work with on your own in the future. THIS LIST IS OPTIONAL and is not required to graduate from the Flex Path course.
More details are available inside the OPTIONAL-challenge-problems-for-later
folder.
Note:
For the first few exercises in this repository, we have included example JS code you can use to test your solutions.
But, after the first few exercises we don't provide it anymore.
As a Software Developer, you will have to both solve a problem given to you and come up with code on your own to test that your solution to that problem actually works.
This is an important skill to build, and it is vital to being able to do this job.
Therefore, we want you to start getting comfortable writing JavaScript code to test that your solutions work as intended.
-
Function Declarations and Expressions:
- How to define functions using declarations and expressions.
- Differences between the two, including hoisting behavior.
-
Arrow Functions:
- Syntax and differences from traditional function expressions.
- Limitations of arrow functions, like the lack of
this
binding.
-
Function Constructor:
- Using the
Function
constructor to create functions dynamically.
- Using the
-
Recursion:
- Understanding recursive functions and the importance of base cases.
-
Immediately Invoked Function Expressions (IIFE):
- Syntax and use cases for self-executing functions.
-
Function Parameters:
- Differentiating between parameters and arguments.
- Concepts of pass-by-value and pass-by-reference.
- Using default parameters for safer function calls.
- Understanding and using the
arguments
object. - Using rest parameters to handle an indefinite number of arguments.
-
Passing Functions as Arguments (Callbacks):
- Creating higher-order functions that accept other functions as arguments.
- Common use cases, like asynchronous programming with
setTimeout
andsetInterval
.
-
Function Scope and Closures:
- How variable scope works in JavaScript.
- Understanding closures and how inner functions retain access to outer variables.
-
The
this
Keyword:- How
this
behaves in different contexts (global, function, and method). - Differences in
this
behavior in arrow functions. - Using
bind()
,call()
, andapply()
to controlthis
.
- How