3 ms·
const w = (fn, _) => function(...args){ return (_ = fn(...args)) === null ? undefined : _; }; document.getElementById = w(document.getElementById.bind(d
by anonytrary 6y ago
const w = (fn, _) => function(...args){
return (_ = fn(...args)) === null ? undefined : _;
};
document.getElementById = w(document.getElementById.bind(document));
- cmroanirgo 6y agoI seriously hope this is joke code. Returning undefined for null, as well as changing dom functions is a great way to ensure unintended side effects will creep into your code.
- philihp 6y agoFor sure you wouldn’t actually commit this, but it’s for sure interesting to do the mental gymnastics to understand it.
- anonytrary 6y agoIt is an illustration of a concept. I wouldn't call it a joke, but I also wouldn't use it.