JavaScript MCQs with answers Page - 5

Here, you will find a collection of MCQ questions on JavaScript. Go through these questions to enhance your preparation for upcoming examinations and interviews.

To check the correct answer, simply click the View Answer button provided for each question.

Have your own questions to contribute? Click the button below to share your MCQs with others!

+ Add Question

A

Admin • 828.03K Points
Coach

Q. Which is an equivalent code to invoke a function fun of class opt that expects two arguments p and q?

  • (A) opt.fun(p,q);
  • (B) fun(p,q);
  • (C) opt.fun(p) && opt.fun(q);
  • (D) opt(p,q);

A

Admin • 828.03K Points
Coach

Q. Which of the following is the correct code for invoking a function without this keyword at all, and also too determine whether the strict mode is in effect?

  • (A) mode strict = (function { });
  • (B) var strict = (function { return this; });
  • (C) mode strict = (function() { return !this; }());
  • (D) var strict = (function() { return !this; }());

A

Admin • 828.03K Points
Coach

Q. Consider the following code snippet.
What will be the result of this code?

Code:
function hypotenuse(p, q) 
{
       function square(n) 
       { 
            return n*n; 
       }
       return Math.sqrt(square(p) + square(q));
}
  • (A) Square of sum of p and q
  • (B) Sum of p and q square
  • (C) Sum of square of p and q
  • (D) All of above

A

Admin • 828.03K Points
Coach

Q. A function with no return value is called

  • (A) Dynamic function
  • (B) Static function
  • (C) Method
  • (D) Procedures

A

Admin • 828.03K Points
Coach

Q. What will happen if a return statement does not have an associated expression?

  • (A) It will throw an exception
  • (B) It will throw an error
  • (C) It returns the value 0
  • (D) It returns the undefined value

A

Admin • 828.03K Points
Coach

Q. What is the purpose of a return statement in a function?

  • (A) Stops executing the function and returns the value
  • (B) Returns the value and stops executing the function
  • (C) Returns the value and stops the program
  • (D) Returns the value and continues executing rest of the statements, if any

A

Admin • 828.03K Points
Coach

Q. When does the function name become optional in JavaScript?

  • (A) When the function is predefined
  • (B) when the function is called
  • (C) When the function is defined as expressions
  • (D) When the function is defined as a looping statement

A

Admin • 828.03K Points
Coach

Q. Consider the following code snippet.
What will the above code snippet result ?

Code:
function output(n) 
{
    for(var v in n)
      console.log(v + ": " + n[v] + "
");
}
  • (A) prints only one property
  • (B) Prints the contents of each property of n
  • (C) prints the address of elements
  • (D) Returns undefined

A

Admin • 828.03K Points
Coach

Q. The function definitions in JavaScript begins with

  • (A) Return type and Identifier
  • (B) Return type, Function keyword, Identifier and Parentheses
  • (C) Identifier and Return type
  • (D) Identifier and Parentheses

A

Admin • 828.03K Points
Coach

Q. Among the keywords below, which one is not a statement?

  • (A) use strict
  • (B) if
  • (C) with
  • (D) debugger

Add MCQ in this Category

If you want to share an MCQ question in this category, it's a great idea! It will be helpful for many other students using this website.

Share Your MCQ