🟒 EasyFunctionsπŸ“– Theory Question

How do arrow functions differ from regular functions?

πŸ’‘

Hint

No own this, no arguments object, no new, no prototype

Full Answer

Arrow functions are not just shorter syntax β€” key behavioral differences:

  • No own this β€” inherits lexical this from outer scope
  • No arguments object β€” use rest params (...args)
  • Cannot be constructors β€” new throws TypeError
  • No prototype property
const obj = {
  name: 'Dev',
  regular() { console.log(this.name); },  // 'Dev'
  arrow: () => console.log(this.name),    // undefined
};
πŸ’‘ Use arrow fns for callbacks (inherit this). Use regular fns for methods and constructors.

More Functions Questions

🟒 EasyWhat is the difference between call, apply, and bind?β†’πŸŸ’ EasyWhat is a pure function and why does it matter?β†’πŸŸ’ EasyWhat are Higher-Order Functions (HOF)?β†’πŸŸ’ EasyWhat is an IIFE (Immediately Invoked Function Expression) and when do you use it?β†’

Practice this in a timed sprint β†’

5 free questions, no signup required

⚑ Start Sprint