This post is taken from my blog, so be sure to check it out for more up-to-date content 😉
By now, all of major web development languages can be co...
For further actions, you may consider blocking this person and/or reporting abuse
7, 6, and 4 are pretty discouraged.
!!
and>>
have terrible readability.Unless you're just doing something quick and hacky, inline styles violate Separation of Concerns.
!!
is a pretty standard way to convert to Boolean, but I definitely agree on every other point.Both of these are identical in javascript. Conditional operators only operate on the truthiness of variables to begin with, and that includes ternary notation. The only time I think I'd use it is when I need to export the truthiness of a variable to another module or API without revealing the actual content — principle of least privelege, or something like that.
Use
!!
when you need to, but seriously consider whether or not you need to. Most of the time, I think you won't.Nice. 1 seems nice, but new elements to the editable style block will be wrapped in
div
s so won't be processed as style rules, but you can edit existing rules i.e adding rules to the body block, but not add a rule for.some-class
I have a coworker who is always angry about the !! operator, but we use TypeScript so if you don’t turn your truthy value into a Boolean sometimes it won’t compile!
Nice post 👍🏻
You can always use
Boolean(var)
if you think its worth it ;)Same!
CSS centering is definitely a trick. Sometimes it works and sometimes it doesn't
Cute!
Thanks for ever