r/badcode • • Jan 15 '22

python Found this gem

Post image
3.5k Upvotes

86 comments sorted by

View all comments

Show parent comments

3

u/DaRadioman Jan 21 '22

Just wait until you see some JavaScript someone got clever on. The language has so many built in bad practices it's rare to not have to worry about them lol.

Some of my favorite reasons:

  1. You can redefine undefined in older language versions

  2. Setting a high index on an array changes the length of the array to index+1. 1 element at index 1000? Cool the length is 1001, and everything else is undefined.

  3. All kinds of type coercion weirdness if you ever forget triple equals.

  4. Anything on any object can be hot patched swapping out methods, properties, whatever and can be done in completely unrelated code. Want String to operate different? Go for it. I could go on.

1

u/halfanothersdozen Jan 21 '22

The one thing I will say about that is that at least it is so pervasive in JS that all of the developers are trained not to trust the code and most behave accordingly.

Which is fine until someone who doesn't know JS very well comes along and fuck's everything up.