JavaScript Functions Quiz
Functions in JavaScript are values you can pass around, and they come with a few quirks: missing arguments are undefined, defaults only apply to undefined, and a line break after return changes the result.
Each question is a short snippet with a short explanation.
Functions questions
- How do closures create private variables in JavaScript?
- How do you write a once() function with a closure?
- Can you call a function before it is declared in JavaScript?
- Why can't you call a function expression before it's defined?
- Can you change this on a bound function with call()?
- What is the difference between call and apply in JavaScript?
- Can call() change this in an arrow function?
- When do default parameters apply in JavaScript?
- What does function.length return in JavaScript?
- Is a named function expression's name available outside?
- Why does a return on its own line return undefined?
- What happens when you declare the same function twice?
- What happens when you call a function with missing arguments?