JavaScript MCQs with answers Page - 27

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 • 833K Points
Coach

Q. Which of the following is the parameter used to invoke the Audio() constructor?

  • (A) File type
  • (B) Music type
  • (C) Both File and Music
  • (D) None of these

A

Admin • 833K Points
Coach

Q. Consider the following code snippet

  • (A) Prints the contents of each property of o
  • (B) Returns undefined
  • (C) All of the mentioned
  • (D) None of the mentioned

A

Admin • 833K Points
Coach

Q. Which is an equivalent code to invoke a function m of class o that expects two arguments x and y?

  • (A) o(x,y);
  • (B) o.m(x) && o.m(y);
  • (C) m(x,y);
  • (D) o.m(x,y);

A

Admin • 833K Points
Coach

Q. Consider the following code snippet :

Code:
var grand_Total=eval("10*10+5");
  • (A) 10*10+5
  • (B) 105 as a string
  • (C) 105 as an integer value
  • (D) Exception is thrown

A

Admin • 833K Points
Coach

Q. Do functions in JavaScript necessarily return a value ?

  • (A) It is mandatory
  • (B) Not necessary
  • (C) Few functions return values by default
  • (D) All of the mentioned

A

Admin • 833K Points
Coach

Q. Consider the following code snippet :

Code:
var tensquared = (function(x) {return x*x;}(10));
  • (A) Yes, perfectly
  • (B) Error
  • (C) Exception will be thrown
  • (D) Memory leak

A

Admin • 833K Points
Coach

Q. Consider the following code snippet :

  • (A) 123
  • (B) 123xyz
  • (C) Exception
  • (D) NaN

A

Admin • 833K Points
Coach

Q. What is the difference between the two lines given below ?

Code:
!!(obj1 && obj2);
(obj1 && obj2);
  • (A) Both the lines result in a boolean value “True”
  • (B) Both the lines checks just for the existence of the object alone
  • (C) Both the lines result in a boolean value “False”
  • (D) The first line results in a real boolean value whereas the second line merely checks for the existence of the objects

A

Admin • 833K Points
Coach

Q. Consider the following code snippet : The state stored in d is :

Code:
var c = counter(), d = counter(); 
c.count()
d.count() 
c.reset() 
c.count() 
d.count()
  • (A) 1
  • (B) 0
  • (C) Null
  • (D) Undefined

A

Admin • 833K Points
Coach

Q. Consider the following code snippet:
What does the last statement return ?

Code:
var c = counter(), d = counter(); 
function constfuncs() 
{
    var funcs = [];
    for(var i = 0; i < 10; i++)
        funcs[i] = function() { return i; };
    return funcs;
}
var funcs = constfuncs();
funcs[5]()
  • (A) 9
  • (B) 0
  • (C) 10
  • (D) None

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