QuizzesFunctions — Declarations, Expressions, Arrows, Defaults — Concept Check
intermediate
javascript

Functions — Declarations, Expressions, Arrows, Defaults — Concept Check

Questions on Functions — Declarations, Expressions, Arrows, Defaults. Functions are values: assignable, passable, returnable. The forms differ in hoisting, in whether they have `this` and `arguments`, and in whether they can be used as constructors.

7 minutes 7 questions Pass at 70%
Time Limit
7 minutes - timer starts when you begin
Change Answers Freely
Revisit and change any answer before submitting
Full Review After Submit
Correct answers and explanations shown for every question
Auto-submit on timeout
Quiz submits automatically when time runs out

Questions in this quiz

7 questions on Functions — Declarations, Expressions, Arrows, Defaults — Concept Check. Work through them here, then start the quiz to answer them and see your score.

  1. 1.You have a function expression assigned to a variable. What happens if you call it before its definition?

    • AReferenceError occurs due to temporal dead zone
    • BSyntaxError occurs due to invalid syntax
    • CTypeError occurs because it's not a function
    • DFunction executes normally due to hoisting
  2. 2.You want to create a utility function that can be used as a constructor. Which function form should you use?

    • AAnonymous arrow function
    • BFunction declaration
    • CFunction expression
    • DArrow function
  3. 3.A developer uses an arrow function to handle an event in a class component. What issue might arise?

    • AThe arrow function lacks its own 'this', causing incorrect context
    • BArrow functions do not support default parameters
    • CArrow functions cannot access 'arguments' object
    • DArrow functions are slower than declarations
  4. 4.You have a function with default parameters. What happens if you pass 'undefined' for a parameter?

    • AThe function skips execution
    • BA TypeError is thrown
    • CThe default value is used for that parameter
    • D'undefined' is treated as a value and no default is used
  5. 5.Why might you prefer a rest parameter over the 'arguments' object in a function?

    • ARest parameters are real arrays, unlike 'arguments'
    • BRest parameters are faster than 'arguments'
    • CRest parameters can be used as constructors
    • DRest parameters are hoisted
  6. 6.A developer tries to use an arrow function as a constructor. What happens?

    • AThe function works as expected
    • BReferenceError: function not defined
    • CSyntaxError: invalid function syntax
    • DTypeError: arrow functions are not constructors
  7. 7.What is the result of calling 'paginate(undefined, 50)' where 'paginate' has default parameters?

    • ABoth page and size default to 1 and 20
    • BTypeError due to undefined parameter
    • Cpage is undefined, size is 50
    • Dpage defaults to 1, size is 50