r/ProgrammerHumor • • May 20 '22

Meme Found Reddit video player source code

Post image
42.9k Upvotes

533 comments sorted by

View all comments

Show parent comments

0

u/[deleted] May 20 '22

[deleted]

1

u/Thenderick May 20 '22

Oh that makes sense. I thought it had something to do with scoping/hoisting but don't know for sure

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.