9 ms·
``` const $ = document.querySelector.bind(document); $('.box').hidden = true; $('.box').hidden = false; ```
by jacobr 3y ago
```
const $ = document.querySelector.bind(document);
$('.box').hidden = true;
$('.box').hidden = false;
```
- troupo 3y ago1. Not really. jQuery is designed not to fail. So if there's no `.box` on the page, jQuery will not do anything. `querySelector` may return null, so `$('.box').hidden` will hard break your page if you're not careful enough 2. `$('.box').hide()` is just one such example. The hilarious https://youmightnotneedjquery.com/ https://youmightnotneedjquery.com/ shows that jQuery remains more consistent, concise, and composable than most things in modern browser APIs
- just_testing 3y agojumping in on this bandwagon... I sometimes look https://youmightnotneedjquery.com https://youmightnotneedjquery.com when I forget how to do something with jQuery. Also, do you know if there is a jQuery-like that actually throws exceptions? Having `$('.box').hide()` tell me there is no `.box` would be pretty useful.