Typo - No declaration made?

On page 215, it says “Declare an instance variable named $formElement in formhandler.js” but there’s no declaration of the variable. The only time I see the variable is with this line in bold:

this.formElement = (selector);

Is this the same thing as declaring it? I was expecting this at the top of the function:

var $formElement;

Hi @JSLearner, var nameOfVar and this.nameOfVar are not quite the same thing. When you declare a variable with var nameOfVar, you are creating a local variable that is available anywhere within that function, but nowhere else. We use local variables for almost everything in JavaScript.

But sometimes, we need to bundle up data and functionality into the same package (Object Oriented Programming). So your formhandler prototype functions (similar to instance methods if you’re familiar with Java’s take on OOP) can “attach” data to the object with this. We colloquially refer to these as “instance variables,” “instance properties,” or sometimes just “properties.”

If you feel fuzzy on OOP, Mozilla has a great series that introduces OOP with JS examples: https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/Object-oriented_JS