nucliweb
6/14/2015 - 7:59 PM

Use querySelector with .bind() as a shortcut to familiar function names

Use querySelector with .bind() as a shortcut to familiar function names

// returns first element selected - $('input[name="food"]')
var $ = document.querySelector.bind(document);
// return array of selected elements - $$('img.dog')
var $$ = document.querySelectorAll.bind(document);

// Credit: https://twitter.com/wesbos/status/608341616173182977