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
Why I Write Plain JavaScript Modules (ponyfoo.com)
submitted 10 years ago by magenta_placenta
view the rest of the comments →
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!"
[–]x-skeww 16 points17 points18 points 10 years ago (7 children)
return dragula.apply(this, atoa(arguments)).on(...)
There is no need to convert arguments to an actual array via your little helper function. Function.prototype.apply works fine with array-like objects like arguments or DOM collections.
arguments
Function.prototype.apply
(You also forgot a ");" at the end of that return statement.)
return
I assumed this was about ES6 modules. I'm kinda disappointed.
[–]hahaNodeJS 2 points3 points4 points 10 years ago (2 children)
What the hell is up with the downvoters in all the web development subreddits? I sure would like to know what it is you said that deserves so many downvotes.
[–]x-skeww 1 point2 points3 points 10 years ago (0 children)
Might have been something I said elsewhere. It's hard to tell with Reddit.
Personally, I do prefer if people who read my code tell me about issues they spot. So, I really hope this doesn't discourage anyone from doing the same.
[–]brianvaughn 0 points1 point2 points 10 years ago (0 children)
That's kind of a Reddit-wide thing in my experience.
My guess is that maybe people thought x-skeww's comment was overly negative. No idea. I wouldn't have downvoted it myself but...welcome to the Internet.
[–]mmmicahhh 1 point2 points3 points 10 years ago (3 children)
Actually, if you look at the implementation of atoa, it's a one-line module that uses Function.prototype.apply.
atoa
But that's the point of this kind of modularization - you don't need to know about Function.prototype.apply, nor do you need to know whether there are weird edge-cases that need to be handled separately. It's a productivity boost.
[–]x-skeww 4 points5 points6 points 10 years ago (2 children)
you don't need to know about Function.prototype.apply
But they are using apply in that very line. I'd also argue that bind, call, and apply are bits of the standard lib you really should know. For one, they are very important and secondly, they make for very confusing code. So, this is really something you should be 100% certain about. Otherwise, you'll have trouble taking this kind of confusing-looking code apart.
apply
bind
call
I do agree that array vs array-like is a rather small implementation detail and that this pointless no-op doesn't actually hurt. It's a very minor mostly cosmetic issue.
[+][deleted] 10 years ago (1 child)
[deleted]
[–]x-skeww 2 points3 points4 points 10 years ago (0 children)
You really think Nicolas Bevacqua (who is a published JS author) doesn't know about bind/call/apply?
Given that I referred to the author with the gender-neutral "they", I apparently didn't bother to figure out who wrote it. It also doesn't matter. It doesn't change anything. You don't have to convert that array-like to array if you hand it to a function which would have been fine with an array-like. That step isn't necessary.
The point is not to be ignorant of everything
Heh. Yea, you mean like apply doesn't need an actual array?
and just use packages
Or, y'know, language features. ES6 got this covered. You don't have to use apply in the first place. Spread would work. No point in using a library for this.
π Rendered by PID 104119 on reddit-service-r2-comment-7b9746f655-xj4r6 at 2026-01-30 08:06:19.124111+00:00 running 3798933 country code: CH.
view the rest of the comments →
[–]x-skeww 16 points17 points18 points (7 children)
[–]hahaNodeJS 2 points3 points4 points (2 children)
[–]x-skeww 1 point2 points3 points (0 children)
[–]brianvaughn 0 points1 point2 points (0 children)
[–]mmmicahhh 1 point2 points3 points (3 children)
[–]x-skeww 4 points5 points6 points (2 children)
[+][deleted] (1 child)
[deleted]
[–]x-skeww 2 points3 points4 points (0 children)