r/javascript • u/Objective_Mind1212 • Jul 25 '21
Useful Javascript Tricks and Tips
https://kush01.hashnode.dev/useful-javascript-tricks-and-tips[removed] — view removed post
0
Upvotes
8
u/redsandsfort Jul 25 '21
better title: "How to get your PR declined"
1
u/cutebabli9 Jul 25 '21
What's wrong with this trick?
//longhand if (x === 'abc' || x === 'def' || x === 'ghi' || x ==='jkl') { //logic } //shorthand if (\['abc', 'def', 'ghi', 'jkl'\].includes(x)) { //logic }1
u/backtickbot Jul 25 '21
1
u/960321203112293 Jul 25 '21 edited Jul 25 '21
myArray.length = 0; // myArray will be equal to [].
Ah yes, because simply setting the length to 0 is much more cost effective and readable vs myArray = [];
/s
•
u/Ustice Jul 25 '21
While your question may be relevant to you, it's not particularly relevant to the rest of the subreddit and honestly belongs much better in /r/LearnJavascript.