Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I wrote my first jQuery lite selector clone a bit ago, any feedback would be appreciated, especially since I don't see the need to separate out querySelector & querySelectorAll

``` const $ = (param) => { if (typeof param === "string" || param instanceof String) { const elm = document.querySelectorAll(param); return elm.length > 1 ? elm : document.querySelector(param); } else { return [param].length === 1 ? [param][0] : [param]; } }; ```



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: