LearnFrenzy
Sign in Take a free test

Arrow Functions · Exercise 1 of 4

Arrow Functions Arrow Functions MCQ

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

Fifteen multiple-choice questions on JavaScript arrow functions: syntax and implicit return, returning objects, lexical this, arrows as methods, arguments, new and prototype, call/apply/bind, hoisting, class fields and syntax rules. Pick an option to check your answer instantly.

Question 1 Easy

Which arrow function returns x * 2?

A (x) => { x * 2 }
B (x) => { x * 2; }
C (x) => { return; x * 2 }
D (x) => x * 2
Question page & discussion
Question 2 Easy

Which arrow function returns the object { ok: true }?

A () => { ok: true }
B () => [ok: true]
C () => ({ ok: true })
D () => return { ok: true }
Question page & discussion
Question 3 Medium

Where does an arrow function get its this from?

A From the object before the dot when it is called
B Always from the global object
C From the first argument
D From the enclosing scope where the arrow is defined
Question page & discussion
Question 4 Medium

How should an arrow function access all the arguments it was called with?

A With the arguments object, as in regular functions
B With this.arguments
C Arrow functions cannot receive arguments
D With a rest parameter: (...args) => args
Question page & discussion
Question 5 Medium

What happens with const Person = (name) => { this.name = name; }; new Person("Asha");?

A TypeError: Person is not a constructor
B It creates { name: "Asha" }
C It returns undefined
D It sets a global variable name
Question page & discussion
Question 6 Medium

Why does const user = { name: "Asha", hi: () => this.name }; not return "Asha" from user.hi()?

A The arrow takes this from the scope around the object literal, not from user
B Object methods must be async
C name must be a getter
D The arrow needs braces
Question page & discussion
Question 7 Hard

What does arrowFn.call(obj, 1, 2) do?

A Calls it with this set to obj
B Throws a TypeError
C Calls the arrow with arguments 1 and 2, but its this stays the lexical this – obj is ignored
D Returns a bound copy without calling it
Question page & discussion
Question 8 Medium

What happens when greet() is called on the line before const greet = () => "hi";?

A It returns "hi"
B ReferenceError – const greet is in its temporal dead zone
C It returns undefined
D TypeError: greet is not a function
Question page & discussion
Question 9 Easy

Where is an arrow function the best choice?

A A method on Product.prototype that uses this
B A constructor
C A generator
D A callback inside a method that needs the method's this, e.g. this.items.map(i => i * this.rate)
Question page & discussion
Question 10 Medium

Why is Car.prototype.start = () => this.engine.on(); a bug?

A The arrow's this is not the car instance, so this.engine is not the car's engine
B Prototype methods cannot be functions
C Arrow functions are slower on prototypes
D start is a reserved word
Question page & discussion

Ready to test your Programming?

Timed online tests with instant scores and explanations.

Search LearnFrenzy

Esc

Quick links