8 ms·
I will never understand why these examples are considered abuse as they exhibit standard behavior. It's just as if I were to write the following JavaScript:
by msimpson 9y ago
I will never understand why these examples are considered abuse as they exhibit standard behavior.
It's just as if I were to write the following JavaScript:
node.classList[ isHidden ? 'add' : 'remove' ]( 'hide' );
I'm simply using a ternary and a bit of reflection, but the arguments regarding "correctness" this engenders...
- pouta 9y agoCan you explain a bit further what the code you posted does?
- msimpson 9y agoElement.classList: https://developer.mozilla.org/en-US/docs/Web/API/Element/classList https://developer.mozilla.org/en-US/docs/Web/API/Element/cla... Property Accessors (Bracket Notation): https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Property_Accessors#Bracket_notation https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe... Conditional (ternary) Operator: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Conditional_Operator https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
- deleted 9y ago[deleted]
- euyyn 9y agoAnd it's even generous of you to call that reflection.