Q
What is the output of function test() { return 2 + 2; } console.log(test());?

Answer & Solution

Answer: Option C
Solution:
The function test returns 4, so console.log(test()) outputs 4.
Related Questions on Average

How can you invoke a function using the call method?

A). myFunction.call();

B). myFunction.call(this);

C). call.myFunction();

D). call(myFunction);

How do you invoke a method named greet on an object person?

A). person.greet;

B). person.greet();

C). greet(person);

D). persongreet;

What is the output of function multiply(x, y) { return x * y; } var result = multiply(5, 10); console.log(result);?

A). 50

B). 510

C). undefined

D). multiply

Which of the following is an example of an Immediately Invoked Function Expression (IIFE)?

A). function() {}();

B). (function() {})();

C). function() {}

D). (function {})();

Which of these is the correct way to define and immediately invoke a function?

A). function() { return 1; };

B). (function() { return 1; })();

C). function() { return 1; }();

D). function {}()

How can you invoke a function stored in a variable myFunc?

A). myFunc();

B). call myFunc;

C). myFunc[];

D). invoke(myFunc);

What will function greet() { console.log('Hi'); } var x = greet; x(); output?

A). Hi

B). undefined

C). x

D). greet

What does return do inside a function?

A). Stops the function

B). Returns a value to the caller

C). Both A and B

D). Declares a variable

How can you invoke a function named init only once when the script runs?

A). init;

B). (init)();

C). init();

D). function init() {}();

What is the output of var test = function() { return 5; }; console.log(test());?

A). test

B). 5

C). undefined

D). function