(function(){// Is necessary apply the `bind` method// to set `this` in the right contextconst$=document.querySelector.bind(document);// more code...})();
This saves the time of going to the documentation or being confused, but it is not redundant, is the main idea that I'm trying to share, IMHO the comments are useful always in the correct way.
I love React's dangerouslySetInnerHTML which replaces a lot of documentation and comments and forces the user to understand what's going on. If you don't know why it says "dangerous", you can look it up.
Much better than
//This is dangerous, read this post about XSS:setInnerHTML
Because the comment would never get ported across all the use cases (obviously, given it's a library).
But most code doesn't live up to the scrutiny of library code and comments, used properly, are a perfectly reasonable part of the toolbelt.
I'm a fan of Open Source and have a growing interest in serverless and edge computing. I'm not a big fan of spiders, but they're doing good work eating bugs. I also stream on Twitch.
Good post, thanks for sharing Ben.
Maybe this can be an simple example:
This saves the time of going to the documentation or being confused, but it is not redundant, is the main idea that I'm trying to share, IMHO the comments are useful always in the correct way.
I love React's
dangerouslySetInnerHTML
which replaces a lot of documentation and comments and forces the user to understand what's going on. If you don't know why it says "dangerous", you can look it up.Much better than
Because the comment would never get ported across all the use cases (obviously, given it's a library).
But most code doesn't live up to the scrutiny of library code and comments, used properly, are a perfectly reasonable part of the toolbelt.
Yes, yes and yes !
I have never used React but
dangerouslySetInnerHTML
is so clear !Yeah, I've only ever used it once and it was to inject release notes into a component from an external HTML file. yolo.