Home / Programming MCQs / JavaScript MCQs / Question

Y

Yogesh • 7.43K Points
Tutor III

Q. Which of the following functions is a valid type of function that javascript supports?

(A) named function
(B) anonymous function
(C) Both A and B are true.
(D) None of the above
Explanation by: Yogesh
A function in JavaScript can be named or anonymous.
Here is a typical example of a named function:

function sayHello()
{
  alert("Hello World!");
}
sayHello();

Here is a typical example of an anonymous function:
var sayHello = function()
{
  alert("Hello World!");
}
sayHello();

You must be Logged in to update hint/solution

Discusssion

Login to discuss.