Can You Find the Bug in This Code?
victorzhou.com
Can You Find the Bug in This Code?
1–10 of 64 posts
Re: Can You Find the Bug in This Code?
#2When you assume the compiler reads it the same way your brain does :)
Re: Can You Find the Bug in This Code?
#3I feel good that my first thought of fixing it would have created the solution.
There were obvious errors in my mind that I would fix without knowing the whole dissertation on why it happened.
So maybe if the question was, "Can you repair this code", I would excel.
Re: Can You Find the Bug in This Code?
#4Always prepend ( and [ with ;
I also prefer void function () {} for this. Void the result of this function expression which I immediately invoke.
Re: Can You Find the Bug in This Code?
#5Semicolons are usually optional in JS. The 'usually' part if why it's a good idea to enforce usage of them to avoid situations like this.
You don't even need to do IEEs for this - running a function on an inline-declared array has a high probability of creeping the array up as an index on the previous expression.
Re: Can You Find the Bug in This Code?
#6Always prepend ( and [ with ; I also prefer void function () {} for this. Void the result of this function expression which I immediately invoke.
Correction: void function () {}()
Re: Can You Find the Bug in This Code?
#7The real bug is the failure to use semi-colons. I literally cannot comprehend the non-use of semi-colons in JS.
Re: Can You Find the Bug in This Code?
#8;)
Re: Can You Find the Bug in This Code?
#9What kind of heathen omits semicolons in JavaScript
Thats like neglecting punctuation in English You can but the punctuation makes it much easier to read
Re: Can You Find the Bug in This Code?
#10I refuse to use semi-colons in TS/JS, unless that conflicts with existing code standards. I feel like it's as if I'm using semi-colons in Go. This can easily be avoided by writing clearer code.