Functions & Arrow Functions
Difficulty: easy
Overview
Function declarations are hoisted fully. Function expressions and arrow functions are not hoisted. Arrow functions do not have their own this, arguments, or prototype. Default parameters provide fallback values. Rest parameters (...args) collect extra arguments into an array. Functions are first-class objects — they can be assigned, passed, and returned.
Practice Linked Questions
Q1. Which of the following correctly declares an arrow function?
Select one answer before revealing.
Q2. What is the key difference between a function declaration and a function expression?
Select one answer before revealing.
Q3. What does a function return if no `return` statement is specified?
Select one answer before revealing.
Q4. What is the output? ```js const greet = (name = "World") => `Hello, ${name}!`; console.log(greet()); ```
Select one answer before revealing.
Q5. What does the rest parameter (`...args`) do?
Select one answer before revealing.
Q6. What is the output? ```js const add = (...nums) => nums.reduce((sum, n) => sum + n, 0); console.log(add(1, 2, 3, 4)); ```
Select one answer before revealing.
Q7. What is the `this` keyword inside an arrow function?
Select one answer before revealing.
Q8. Which of the following are ES6+ features? (More than one answer may be correct.)
Select one answer before revealing.