JavaScript MCQs with answers Page - 44

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. What will be the output of the following JavaScript code?

Code:
< p id="demo">< /p>
< script>
var a = "10"; var b = "10"; var c = a * b; document.getElementById ("demo").innerHTML = c; < /script>
  • (A) 10
  • (B) 100
  • (C) 1000
  • (D) error

A

Admin • 833K Points
Coach

Q. What will be the output of the following JavaScript code?

Code:
< p id="demo">< /p>
< script>
var a = 20;
var b = "30";
document.getElementById ("demo").innerHTML = x + y;
< /script>
  • (A) 50
  • (B) 20+30
  • (C) 2030
  • (D) error

A

Admin • 833K Points
Coach

Q. What is the code required to delete all weight tags?

  • (A) delete pt..weight;
  • (B) delete pt;
  • (C) delete pt.element[all];
  • (D) delete weight(pt).all;

A

Admin • 833K Points
Coach

Q. Which of the following is the descendant operator?

  • (A) ..
  • (B) ...
  • (C) *
  • (D) @

A

Admin • 833K Points
Coach

Q. What is the code to be used to trim whitespaces?

  • (A) let trimmed = for(l in lines));
  • (B) let trimmed = l.trim();
  • (C) let trimmed = (trim(l));
  • (D) let trimmed = (l.trim() for (l in lines));

A

Admin • 833K Points
Coach

Q. What does the following JavaScript code snippet do?

Code:
data.sort(function(a,b),b-a);
  • (A) Sort in reverse numerical order
  • (B) Sort in reverse alphabetical order
  • (C) Sort in the chronological order
  • (D) Sort in the alphabetical order

A

Admin • 833K Points
Coach

Q. What convenience does the following JavaScript code snippet provide?

Code:
let suc = function(a) a+1, yes = function() true, no = function() false;
  • (A) Shorthand expression
  • (B) No convenience
  • (C) Modular behaviour
  • (D) Functional behaviour

A

Admin • 833K Points
Coach

Q. The ________ operator is used to create an instance of an object.

  • (A) new
  • (B) find
  • (C) self
  • (D) this

A

Admin • 833K Points
Coach

Q. The syntax for adding a property to an object is?

  • (A) objectName.objectProperty == propertyValue;
  • (B) objectName.objectProperty = propertyValue;
  • (C) objectProperty = propertyValue;
  • (D) objectProperty == propertyValue;

A

Admin • 833K Points
Coach

Q. The capability to store one object inside another object known as?

  • (A) Polymorphism
  • (B) Inheritance
  • (C) Aggregation
  • (D) Encapsulation

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