This forum is now read-only. Please use our new forums! Go to forums
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
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?
Popular free courses
- Free Course
Learn SQL
In this SQL course, you'll learn how to manage large datasets and analyze real data using the standard data management language.Beginner friendly,4 LessonsLanguage Fluency - Free Course
Learn JavaScript
Learn how to use JavaScript — a powerful and flexible programming language for adding website interactivity.Beginner friendly,11 LessonsLanguage Fluency - Free Course
Learn HTML
Start at the beginning by learning HTML basics — an important foundation for building and editing web pages.Beginner friendly,6 LessonsLanguage Fluency
4 comments
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
why is function not called before the variable declaration?
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.
what does the above sentence mean?