Misunderstanding of the syntax


#1

in the code below how the computer understand that (number=6), despite there is no variable declaration.
in the first row, the variable divideByThree is a function so I assume it should equal the result of this function!

so is it automatically defined as a variable when it's inside the brackets (), and what if there are many inside ()?


var divideByThree = function (number) {
    var val = number / 3;
    console.log(val);
};
divideByThree(6)


#2

a function parameter (number) serves as a placeholder till you supply an argument at function call (6 in this case)

if the number of parameters and arguments don't match, you get an error


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.