r/node • • Apr 14 '24

JavaScript Functions - 4 Ways

Post image
208 Upvotes

79 comments sorted by

View all comments

Show parent comments

-11

u/azhder Apr 14 '24

If what you say is correct (I highly doubt), you have learnt JavaScript in the 90s.

The function declaration is hoisted and doesn’t even respect blocks like if-else if you happen to forget and put the same name in both paths.

5

u/damnNamesAreTaken Apr 14 '24

What are you telling me I'm incorrect about? The arrow function wasn't a thing until around ten years ago. I almost never use JavaScript so I never kept up on what the true differences were other than syntax. I learned JS in the mid 2000s.

-15

u/azhder Apr 14 '24 edited Apr 14 '24

I didn’t say you are incorrect, I said I doubt you have learnt it in the 90s. The function expression existed at least in the ES3 standard, released by the end of 1999.

1

u/Shaper_pmp Apr 15 '24

I didn’t say you are incorrect, I said I doubt you have learnt it in the 90s.

Dude, there are some of us here who wrote our first JS in Netscape Navigator 2.0beta in 1995.

JS was also orders of magnitude simpler for years before widespread support for Msxml2.XMLHTTP/XMLHTTPRequest made it feasible to even start writing complicated client-side applications in the mid 2000s, so lacking huge, modular codebases there was basically zero concern about things like restricting scoping or polluting the global scope.

If someone wrote JS early in their career and then didn't really stay up to date, it's not at all surprising that they might remember function definitions, but not really comprehend the point of even function expressions, let alone things like arrow-syntax.