dimanche 28 décembre 2014

Why doesn't my javascript function throwing up an error?


After invoking my function, I was startled by the fact that my function did not throw up an error due having "length" inside my first function statement and not in the function's parameters. My question: Why doesn't my function throw an undefined,error, or the like? Shouldn't it throw up an error because "length" isn't in my function's parameter? If someone could explain how javascript interprets this function in a step-by-step manner that would help me. Here is my code:



function areaRectangle(width, height) {
aRectangle = width * length;
console.log("The area of the rectangle is: " + aRectangle);
}
areaRectangle(10, 7); // My number results in 0




Aucun commentaire:

Enregistrer un commentaire