Your product could be here, in front of thousands of JavaScript developers. Sponsor this spot →
JavaScript Quiz

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

  1. How do closures create private variables in JavaScript?
  2. How do you write a once() function with a closure?
  3. Can you call a function before it is declared in JavaScript?
  4. Why can't you call a function expression before it's defined?
  5. Can you change this on a bound function with call()?
  6. What is the difference between call and apply in JavaScript?
  7. Can call() change this in an arrow function?
  8. When do default parameters apply in JavaScript?
  9. What does function.length return in JavaScript?
  10. Is a named function expression's name available outside?
  11. Why does a return on its own line return undefined?
  12. What happens when you declare the same function twice?
  13. What happens when you call a function with missing arguments?

More topics