Query Select All The Things!

Query Select All The Things!

Almost all the Codepens I’ve written this year have had some form of a JavaScript function that I call qs()(). That’s not a typo! There are two sets of parenthesis following it, and it is good practice as this function uses closures. In just one line, I create a Swiss Army knife of several functions.

There was a paragraph that I didn’t finish regarding why using qs()() should be used instead of jQuery(). Hopefully the editor will be a little more careful next time to let the writers know about these kinds of things such that guys like me don’t forget to finish a thought before its published. :wink:

Whoops! How I described the closures in the long version of my qs()() function was incorrect. Every time you use an arrow function => that creates another scope layer. And if you do it at the beginning, you are setting up a nesting structure. I hope this new code will provide some better clarity.
I’m also going to use JSDoc from now on to describe my functions and arguments (parameters).