I’ve been slowly learning JavaScript over the last few months, and just got bit by something that I think is a mistaken design. I bet it’s bit everyone for whom it’s not their first Algol-like language.
The problem came up with an image that had an “undefined” src property.
I could see it was undefined in Firebug. When the page loads it’s not not undefined. I click on it, and boom it loses its definition. How could that be.
Well, you could have assigned it an undefined value. Let’s look for an assignment. Found it.
Search on Google. Aha. The weirdness. You can call a function with fewer parameters than it defines. The unspecified parameters are (ta dahh) undefined.
Even C, the most laissez-faire language in AlgolLand doesn’t allow this!
Once I knew what I was looking for I found it right off, fixed it, and all is good. ![]()
Adventures in programming with Uncle Davey.