JavaScript MCQs with answers Page - 7

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 one of the following also known as Conditional Expression:

  • (A) Alternative to if-else
  • (B) Switch statement
  • (C) If-then-else statement
  • (D) immediate if

A

Admin • 828.03K Points
Coach

Q. In JavaScript, what is a block of statement?

  • (A) Conditional block
  • (B) block that combines a number of statements into a single compound statement
  • (C) both conditional block and a single statement
  • (D) block that contains a single statement

A

Admin • 828.03K Points
Coach

Q. When interpreter encounters an empty statements, what it will do:

  • (A) Shows a warning
  • (B) Prompts to complete the statement
  • (C) Throws an error
  • (D) Ignores the statements

A

Admin • 828.03K Points
Coach

Q. The "function" and " var" are known as:

  • (A) Keywords
  • (B) Data types
  • (C) Declaration statements
  • (D) Prototypes

A

Admin • 828.03K Points
Coach

Q. In the following given syntax of the switch statement, the Expression is compared with the labels using which one of the following operators?

Code:
switch(expression)  
{  
    statements  
}  
  • (A) ===
  • (B) equals
  • (C) ==
  • (D) None

A

Admin • 828.03K Points
Coach

Q. What will happen, if the following JavaScript code is executed?

Code:
var count =0;  
while (count <10)  
{  
     console.log(count);  
     count++;  
}  
  • (A) An error is displayed
  • (B) An exception is thrown
  • (C) The values of count variable are logged or stored in a particular location or storage
  • (D) The value of count from 0 to 9 is displayed in the console

A

Admin • 828.03K Points
Coach

Q. Which of the following is the correct output for the following JavaScript code:

Code:
Int x=8;  
if(x>9)  
{  
document.write(9);  
}  
else  
{  
document.write(x);  
}  
  • (A) 9
  • (B) 0
  • (C) 8
  • (D) Undefined

A

Admin • 828.03K Points
Coach

Q. Which of the following is the correct output for the following JavaScript code:

Code:
var x=3;  
var y=2;  
var z=0;  
If(x==y)  
document.write(x);  
elseif(x==y)  
document.write(x);  
else  
document.write(z);  
  • (A) 3
  • (B) 0
  • (C) Error
  • (D) 2

A

Admin • 828.03K Points
Coach

Q. Which of the following variables takes precedence over the others if the names are the same?

  • (A) Global variable
  • (B) The local element
  • (C) The two of the above
  • (D) None of the above

A

Admin • 828.03K Points
Coach

Q. Which one of the following is the correct way for calling the JavaScript code?

  • (A) Preprocessor
  • (B) Triggering Event
  • (C) RMI
  • (D) Function/Method

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