Skip to the solution
MediumFrontend7 min read

What is the difference between arrow and regular functions?

637 views

The problem

Question presented to candidate: "What is actually different between an arrow function and a regular function, beyond the shorter syntax?"

What a strong answer should cover:

  • The core distinction: arrow functions have no this of their own -- they capture this lexically from the enclosing scope at definition time, and nothing (call, apply, bind, or how they are invoked) can change that.
  • Arrow functions have no own arguments object -- referencing arguments inside one resolves to an enclosing regular function's arguments, exactly like any other lexically-scoped variable.
  • Arrow functions cannot be used as constructors -- calling new on one throws a real TypeError, because they lack the internal [[Construct]] behavior.
  • Arrow functions have no prototype property at all (it is undefined), unlike regular functions, which get a real, populated prototype object automatically.
  • Arrow functions cannot be generator functions (no yield) and, unlike regular functions, are always anonymous unless assigned to a named binding.
  • None of this makes arrow functions strictly "better" -- they are the right tool specifically when you want to inherit this from the surrounding scope, such as callbacks inside a class method or an event handler.

Code / implementation expected: Yes -- a runnable snippet exercising the this, arguments, constructor, and prototype differences side by side with real observed output.

  • arrow-functions

Try it yourself

Sketch your approach before you read the solution. That is what the interview tests.

Stuck? Get a hint.

A short nudge toward the approach. It will not give the answer away.

Solution

The solution is hidden so you can try first

7 min read Β· 8 sections

Run the code

Edit the code and run it here. Each console line with an expected value becomes a test.

JavaScriptthis, call/apply/bind, and arguments: arrow vs regular (run directly)
JavaScriptArrow functions cannot construct and have no prototype (run directly)

Discussion

Other approaches, follow-ups and how it went in real interviews.

Sign in to join the discussion.

No comments yet. Share how you would answer it.

Question 76 of 165 in JavaScript

Keep your momentum going.

Mark this question solved to track your progress, then take the next one while it is fresh.

Up nextMedium

How would you combine multiple AbortSignals or add a timeout to a fetch request using AbortSignal.any() and AbortSignal.timeout()?

Continue