Assuming that Func is an existing function:
Case 1 is if your function returns a value and you want to store the result, such as in:
function times_ten(num){ return num*10; }
var ten = 10;
var hundred = times_ten(ten);
So now you can use the variable hundred
from now on.
Case 2 is if you are not returning a value, or you don't need to save it:
function write_times_ten(num){ num = num*10; document.write(num); }
var ten = 10;
var hundred = write_times_ten(ten);
Case 3 is slightly more complex.
If you do var something={a:function(){}}
- By creating an object like this, you have all of your functions in the same scope, so you don't pollute the global namespace. This is kind of like creating a class in other languages. jQuery is the biggest example of this I can think of, because for all of what it does, it all is processed by the object jQuery
(or calling a function such as jQuery.parseJSON(json_string)
If you're passing in an object with a function like that, then you are asking Func()
to do something with that function you passed in, like so:
function do_something_times_ten(options){
options.num = options.num*10;
options.do_something(num);
}
var ten = 10;
do_something_times_ten({num:ten,
do_something:function(num){
num = num*10;
document.write(num);
}
}
);
Which would now write out 1000, not 100.