LearnFrenzy
Sign in Take a free test

Functions · Exercise 1 of 4

Functions JavaScript Functions MCQ

  • 15 questions
  • Page 2 of 2
  • Answers explained
0Attempted
0Correct
0Wrong
Directions

Fifteen multiple-choice questions on JavaScript functions: declarations and expressions, hoisting, default and rest parameters, arguments, fn.length, return values, callbacks, higher-order functions, IIFE, pass by sharing and pure functions. Pick an option to check your answer instantly.

Question 11 Easy

A function has two parameters and is called with three arguments, and later with one. What happens?

A A TypeError is thrown in both cases
B A SyntaxError is thrown
C The extra argument is ignored (but in arguments); the missing parameter is undefined
D The missing parameter becomes null
Question page & discussion
Question 12 Hard

In const fact = function calc(n) { … };, where can the name calc be used?

A Only inside the function itself (useful for recursion)
B Anywhere in the file, like fact
C Nowhere – the name is ignored
D Only after the declaration line
Question page & discussion
Question 13 Medium

Which function is pure?

A const log = (msg) => console.log(msg);
B const add = (a, b) => a + b;
C const next = () => ++counter;
D const now = () => Date.now();
Question page & discussion
Question 14 Easy

In setTimeout(showAlert, 1000), what is showAlert?

A A return value
B A promise
C A callback – a function passed to another function to be called later
D An event
Question page & discussion
Question 15 Hard

For function add(item, list = []) { list.push(item); return list; }, what do add(1) and then add(2) return?

A [1] and [1, 2] – the default is created once
B [1] and [2] – the default [] is created fresh at every call
C [1] and undefined
D A TypeError
Question page & discussion
Up next · Exercise 2Predict the Output20 questions

Ready to test your Programming?

Timed online tests with instant scores and explanations.

Search LearnFrenzy

Esc

Quick links