JavaScript MCQs with answers Page - 34

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 keywords is used to define a variable in Javascript?

  • (A) var
  • (B) let
  • (C) Both A and B
  • (D) None of these

A

Admin • 833K Points
Coach

Q. Which of the following methods is used to access HTML elements using Javascript?

  • (A) getElementbyld()
  • (B) getElementsByClassName()
  • (C) Both A and B
  • (D) None of these

A

Admin • 833K Points
Coach

Q. Upon encountering empty statements, what does the Javascript Interpreter do?

  • (A) Throws an error
  • (B) Ignores the statements
  • (C) Gives a warning
  • (D) None of these

A

Admin • 833K Points
Coach

Q. Which of the following methods can be used to display data in some form using Javascript?

  • (A) document.write()
  • (B) console.log()
  • (C) window.alert()
  • (D) All of the above

A

Admin • 833K Points
Coach

Q. In which element we put javascript?

  • (A) <javascript>
  • (B) <scripting>
  • (C) <script>
  • (D) None of These

A

Admin • 833K Points
Coach

Q. the correct place to insert a JavaScript is ?

  • (A) The section
  • (B) The section
  • (C) Both A & B
  • (D) none of these

A

Admin • 833K Points
Coach

Q. Which of the following is the correct syntax for referring to an external script called "xxx.js"?

  • (A) <script src="xxx.js>
  • (B) <script src="xxx.js">
  • (C) <script name="xxx.js">
  • (D) None of these

A

Admin • 833K Points
Coach

Q. What is the code snippet to go back to a history thrice?

  • (A) history(3);
  • (B) history(-3);
  • (C) history.go(-3);
  • (D) history.go(3);

A

Admin • 833K Points
Coach

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

Code:
function myfun()
{
document.getElementById ("demo").innerHTML = Boolean(21 > 15);
}
  • (A) 0
  • (B) true
  • (C) false
  • (D) error

A

Admin • 833K Points
Coach

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

Code:
function myfun()
{
var a = "";
document.getElementById ("demo").innerHTML = Boolean(a);
}
  • (A) undefined
  • (B) false
  • (C) true
  • (D) error

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