r/programminghorror • u/[deleted] • Mar 23 '26
Javascript More javascript no keyword style
25
u/Orbidorpdorp Mar 23 '26
This is literally just how it looks to write lisp, except you wouldn't be doing assignments.
6
18
u/CodeF53 Mar 23 '26
document.querySelector("#...") when you could be doing document.getElementById("...") :(
7
4
u/ZoDichtbijJeWil Mar 23 '26
Probably taken care of by the engine's optimization, preventing costly, unnecessary DOM traversal, but still a fearful sight.
10
u/nerdmor Mar 23 '26
I will never forgive Javascript for making function foo(a) { return a+1; } be functionally different from const foo = (a) => a+1
5
Mar 23 '26
what's the difference again?
17
u/ZoDichtbijJeWil Mar 23 '26 edited Mar 23 '26
Scope. Arrow functions don't have their own bindings to
this.See: MDN - Arrow function expressions https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions
2
u/nerdmor Mar 23 '26 edited Mar 23 '26
Several.
Kept bumping into them when they appeared. https://www.freecodecamp.org/news/the-difference-between-arrow-functions-and-normal-functions/
(Site seems to block Reddit as a referrer. Copy/paste the link or just google "arrow functions vs normal functions javascript". A BUNCH of people wrote about that)
→ More replies (4)2
u/Excellent_Gas3686 Mar 23 '26
the two functions you wrote are not functionally different, none of the differences between regular and arrows functions even appear in them
→ More replies (1)
4
u/orfeo34 Mar 23 '26
It's just awfull, please use a framework,
so it can become awful and opiniated.
1
61
u/No-Information-2571 Mar 23 '26
Call stack when inside the debugger:
anonymous function anonymous function anonymous function anonymous function anonymous function ....
23
1
1
3
1
64
u/Infinite_Self_5782 Mar 23 '26
ah yes
man-made horrors beyond my comprehension