Answer the question
In order to leave comments, you need to log in
How does passing parameters to a javascript function work?
Please explain why in this code:
var a = 3, b = 2, c = 4;
function test(a, b, c) {
var d = b * (a + c);
console.log(d);
}
test(b, c, a);
Answer the question
In order to leave comments, you need to log in
Because the parameters are passed to the place where they are, for example:
var a = 2;
var b = 4;
var c = 5;
function test(x,y,z) {
}
test(a,b,c)
This is an exercise in variable scoping in JavaScript . Variables
inside a function are not the same as outside. They are called the same, it is confusing, but they mean different things. test
a, b, c
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question