0 points
Submitted by swali1
over 6 years

What is function call?

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

thanks

Answer 557acf299113cbe852000022

1 vote

Permalink

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

e.g.

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?

points
over 6 years

4 comments

swali1 over 6 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 over 6 years

why is function not called before the variable declaration?

swali1 over 6 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 over 6 years

what does the above sentence mean?