Last active
August 29, 2015 14:02
-
-
Save toddmotto/e7fcdc18291060e2d2bc to your computer and use it in GitHub Desktop.
104 bytes jQuery-like wrapper, $('.class') returns NodeList, $('.class:first') returns first Node only, optional scoping $('.class', '.parent')
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function $(a,b){return(b||document)['querySelector'+(b=/\:first$/,b.test(a)?'':'All')](a.replace(b,''))} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
if you don't have the array you don't have a jQuery like function …. I think it's not worth drop such feature, 134 bytes are still OK ;-)
edit thought it could have been smaller … well, you can go 103 using
/:first$/
instead of/\:first$/