This forum is now read-only. Please use our new forums! Go to forums

0 points
Submitted by swali1
almost 8 years

What is function call?

how do you call a function in javascript.what is the syntax and a example please.


Answer 557acf299113cbe852000022

1 vote


You call the function by typing its name and putting a value in parentheses. This value is sent to the function’s parameter.


var firstFunction = function(firstParameter)
console.log("Print the " + firstParameter;
firstFunction("string as it's shown.");

In this example the function’s name is firstFunction The parameter’s name is firstParameter

We call the function firstFunction(“string as it’s shown.”);

This sends the string “string as it’s shown.” to the function and the parameter firstParameter takes it’s value.

Now the code inside the function actual reads

“Print the “ + “string as it’s shown.”;

Does that make sense?

almost 8 years


swali1 almost 8 years

yes..Thanks.only the last bit got ehh…“Print the “ + “string as it’s shown.”; was a little tricky..sinmce the elemts in the example you gave were first parameter ,first function.i mean not easy to understand elements.Anyways good example. Thanks

swali1 almost 8 years

why is function not called before the variable declaration?

swali1 almost 8 years

Primitive parameters (such as a number) are passed to functions by value; the value is passed to the function, but if the function changes the value of the parameter, this change is not reflected globally or in the calling function.

swali1 almost 8 years

what does the above sentence mean?