Hilarious Javascript Bugs

So here’s an incredibly contrived bug. Javascript lets you check for a value contained within an array using the “in” operator, à la:

if ('reverse' in stringArray) { ...

As a matter of fact, I did have a weapon property of that exact name, “reverse”. This allows the weapon to strike not only forward at the target, but also backwards at the enemy directly behind the attacker. However, all javascript arrays have a “reverse” function built-in, which reverses the array. Can you see where this is going?

I was mistakenly seeing all attacks as reversals, because the “in” operator apparently not only checks the contents of the array, but also any member functions (or whatever it’s called in Javascript-ese).

Ok here’s a way more amusing bug! So goats love to eat anything right, they’ll eat any kind of vegetarian food, they’ll also eat leather, small metal or glass items, and paper. Scrolls! I had a tame goat following me around, completed a quest or something and a scroll of fire dropped. The goat jumped on the scroll, but instead of eating it the logic had him reading it! FOOMP, I was slain. Took me a bit to figure that one out.



  1. That’s a neat idea: goats turn slightly magical when they consume magic items. Maybe making a goat into the most powerful being in the world by feeding it magical items could be a quest.

Leave a Reply