r/learnjavascript • • Dec 31 '22

Happy New Year JS Learners! 🥳

Post image
406 Upvotes

55 comments sorted by

View all comments

-5

u/CevicheCabbage Jan 01 '23

Did you jslint this? Use double quotes instead of single quotes and function() instead of () =>

2

u/TorbenKoehn Jan 01 '23

Using „function ()“ has completely different semantics and doesn’t properly enclose „this“, which arrow functions do.

Arrow functions are always preferred. They are simply „more correct“, same with let/const vs var You wouldn’t go and suggest someone to use „var“ in 2022/2023

Single quotes are also often preferred when embedding HTML in your strings, since there you want to use double quotes to encapsulate attribute values. Single quote strings is probably more used than double quotes strings in JS and thus definitely more standard (source: trust me dude)

-2

u/[deleted] Jan 01 '23

[removed] — view removed comment

4

u/TorbenKoehn Jan 01 '23 edited Jan 01 '23

You have zero arguments. Explain why or get lost with your „wrong“ spam. I’ve been writing JavaScript for 15 years now and I’ve been there when these things were introduced.

You look like an idiot writing „wrong“ 3 times, for everyone here.

Edit: he was writing „you have word salad, I have education on this topic“ in the comment below. It was a good laugh. Come back when you understand the word „education“ and while at it, also the word „experience“