Recall & Review
beginner
What is a function expression in JavaScript?
A function expression is a way to define a function inside an expression, often assigned to a variable. It can be anonymous or named and is not hoisted like function declarations.
Click to reveal answer
beginner
How do you assign a function expression to a variable?
You write: <code>const myFunc = function() { /* code */ };</code> This stores the function in the variable <code>myFunc</code>.Click to reveal answer
intermediate
What is the difference between a function declaration and a function expression?
Function declarations are hoisted, so you can call them before they appear in code. Function expressions are not hoisted, so you must define them before calling.
Click to reveal answer
beginner
Can function expressions be anonymous? What does that mean?
Yes, function expressions can be anonymous, meaning they have no name. For example: <code>const f = function() { }</code>. The function has no name but is stored in <code>f</code>.Click to reveal answer
intermediate
How do arrow functions relate to function expressions?
Arrow functions are a shorter syntax for writing function expressions. For example: <code>const add = (a, b) => a + b;</code> is a function expression using arrow syntax.Click to reveal answer
Which of these is a valid function expression?
✗ Incorrect
Option A shows a function expression assigned to a variable. Option B is a function declaration.
What happens if you try to call a function expression before it is defined?
✗ Incorrect
Function expressions are not hoisted, so calling them before definition causes an error.
Which is true about anonymous function expressions?
✗ Incorrect
Anonymous functions have no name but can be stored in variables.
How do arrow functions differ from regular function expressions?
✗ Incorrect
Arrow functions use shorter syntax and do not have their own 'this' context.
Which keyword is used to assign a function expression to a variable?
✗ Incorrect
You use
const or let to assign a function expression to a variable.Explain what a function expression is and how it differs from a function declaration.
Think about when you can call the function in your code.
You got /3 concepts.
Describe how arrow functions relate to function expressions and mention one key difference.
Consider syntax and behavior differences.
You got /3 concepts.