r/ProgrammerHumor • • Aug 08 '16

JQuery Does All Things!

https://i.reddituploads.com/b79bb2d6e2f14e65b769686647cc4782?fit=max&h=1536&w=1536&s=ed6be616a7a0467c49330eda9253811e
3.0k Upvotes

207 comments sorted by

View all comments

86

u/[deleted] Aug 08 '16

an old one but a good one.

Just today I googled something to get "try xxx jQuery plugin" which literally could be replaced by 5 lines of vanilla JS.

31

u/gandalfx Aug 08 '16

Well Node developers also like to import packages from NPM that literally contain a trivial one-liner. And that's not even a rare occurrence.

28

u/[deleted] Aug 08 '16

Missing dependency: left-pad .

17

u/DeeSnow97 Aug 08 '16
const leftPad = (s, l, c) => new Array(Math.max(l - s.length, 0)).fill(c || ' ').join('') + s

I'm still struggling to believe the absence of this code took down the world

4

u/[deleted] Aug 08 '16

Not ashamed to admit that this is way more clever and elegant than how I would create a left-pad method. Maybe because I don't do JS much.

1

u/[deleted] Aug 10 '16

And unlike the leftpad function, this isn't quadratic time.