r/ProgrammerHumor • • May 20 '22

Meme Found Reddit video player source code

Post image
42k Upvotes

533 comments sorted by

View all comments

Show parent comment

1

u/timmyfred May 21 '22

They are scoped the same, but function declarations (function x() {}) are hoisted, while with function expressions (const x = function(){}), only the variable declaration is hoisted but not the initialization, ie x will declared but not defined until execution reaches that line.

Additionally, arrow functions have some special properties, namely that they do not bind their own this, arguments, or super. They also have an implied return if written on one line without curly brackets.