Function parameter listed

Function parameter listed
0

#1

What is that case in this example

function test(test1,test2) {
}

When test parameter not used but is required to set before test2?

Thanks


#2

i believe ‘test’ is the name of the function? (not a parameter)


#3

Can you try asking your question a little differently? For example, how is this function called and how are test1 and test2 used inside the function?


#4
$menu.children().outerWidth(function(i, s) {
	test += s;
	test2 += 1;
	test3.push(test4);
});

I and S parameters used. But S is used on first test. The I is not used but if remove the whole is not working. What the logic on this?


#5

Is there any reason that you must remove i?


#6

NO! But from copy paste I know nothing about it. So that I must be something undefinied there because if not not working. But what logic hmm???


#7

let’s say, function test look like this

function test(test1, test2) {
console.log(test2);
}

when you declare function with name test, you make it with paramater call test1 and test2.

function test(test1,test2)

test1 and test2 is the paramater you should give when you call that function “test”.

example

test(10, ‘foo’);

and then, variabel test1 will have value = 10, and variabel test2 will have value = ‘foo’.
the result will display ‘foo’ message on console. because it take value of test2

but if you try to call test function without paramater, you will get error message.

hope this will help


#8

By reading the jquery doc about outerWidth function you will understand what the two parameters mean.