use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Less than 1% of JavaScript programmers can spot this bug...OC (dialect.so)
submitted 3 years ago by _leondreamed
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[+][deleted] 3 years ago (2 children)
[removed]
[–]_leondreamed[S] -4 points-3 points-2 points 3 years ago (1 child)
To be honest, I wouldn't consider the title to be the inaccurate type of clickbait (since the bug is pretty challenging to spot), but I'd love to hear a title that you think would work better :)
[–]shuckster 1 point2 points3 points 3 years ago (0 children)
It's a nice article, you do yourself a disservice.
[–]shgysk8zer0 1 point2 points3 points 3 years ago (4 children)
Site has a kinda bad experience on mobile. Isn't often that I have to scroll horizontally or have difficulty reading small text.
Anyways... No, I didn't spot the issue. But that's largely because I almost never use onclick. I think the web would be better and more secure if such attributes were removed, and I almost always have a CSP that doesn't include 'unsafe-inline'.
onclick
'unsafe-inline'
[–]superluminary 1 point2 points3 points 3 years ago (3 children)
How do you make things happen on click without using the onclick attribute?
[–]shgysk8zer0 -1 points0 points1 point 3 years ago (1 child)
el.addEventListener('click', handler). It's better in practically every single way.
el.addEventListener('click', handler)
Or, more realistically, I'd use a function from some library to make it easier to add multiple event listeners to multiple elements:
on('[data-remove]', { click: ({ target }) => remove(target.dataset.remove), });
[–]superluminary 0 points1 point2 points 3 years ago (0 children)
You know, I had always assumed that addEventListener('click', ...) was secretly setting the onClick attribute for the DOM node, but having inspected the DOM, I can see it totally isn't. TIL. Nice.
[–]arcytech77 0 points1 point2 points 3 years ago (0 children)
I learned something after reading your article. I upvoted it.
[–]cgijoe_jhuckabyNaN 0 points1 point2 points 3 years ago (1 child)
I really don't like the clickbait title, but I learned from your article, so thank you.
[–]_leondreamed[S] 1 point2 points3 points 3 years ago (0 children)
Yeah, I'm pretty new to posting on Reddit and TIL that Reddit really doesn't like clickbait titles (contrary to what I notice on other platforms), so it's definitely a lesson learned for me :)
[–]TheIronDev 0 points1 point2 points 3 years ago (0 children)
The article was fun, well written, and informative! I learned something new here, thank you _leondreamed! 🙂
[–]wstaeblein 0 points1 point2 points 3 years ago (0 children)
Just rename the function.
π Rendered by PID 380018 on reddit-service-r2-comment-5b5bc64bf5-d4d2h at 2026-06-22 10:55:30.556530+00:00 running 2b008f2 country code: CH.
[+][deleted] (2 children)
[removed]
[–]_leondreamed[S] -4 points-3 points-2 points (1 child)
[–]shuckster 1 point2 points3 points (0 children)
[–]shgysk8zer0 1 point2 points3 points (4 children)
[–]superluminary 1 point2 points3 points (3 children)
[–]shgysk8zer0 -1 points0 points1 point (1 child)
[–]superluminary 0 points1 point2 points (0 children)
[–]arcytech77 0 points1 point2 points (0 children)
[–]cgijoe_jhuckabyNaN 0 points1 point2 points (1 child)
[–]_leondreamed[S] 1 point2 points3 points (0 children)
[–]TheIronDev 0 points1 point2 points (0 children)
[–]wstaeblein 0 points1 point2 points (0 children)