Kevin Powell - CommunityKP-C
Kevin Powell - Community13mo ago
20 replies
snxxwyy

picking arrow functions vs regular functions

Hey, i understand that picking whether to use arrow functions or regular functions is sometimes based off of preference but mainly based off of what behavior you'd like, however why are functions such as setTimeout mainly seen to use arrow functions not regular? e.g.
setTimeout(() => {
  console.log("xyz");
}, 1000);
//not
setTimeout(function() {
  console.log("xyz");
}, 1000);

at first glance, there doesn't seem to be any more benefits to one than the other in this case so is this more of a personal preference one?

thanks in advance.
Was this page helpful?