JavaScript MCQs with answers Page - 10

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

Q. See the given code of JavaScript and choose the correct output from the following

Code:
var string1 = "40";  
varvalueinit=50;  
alert( string1 +intvalue);  
  • (A) 4090
  • (B) 90
  • (C) 4050
  • (D) Exception

A

Admin • 831.35K Points
Coach

Q. In JavaScript, what will be used for calling the function definition expression

  • (A) Function prototype
  • (B) Function literal
  • (C) Function calling
  • (D) Function declaration

A

Admin • 831.35K Points
Coach

Q. Which of the following one is the property of the primary expression

  • (A) Contains only keywords
  • (B) basic expressions containing all necessary functions
  • (C) contains variable references alone
  • (D) stand-alone expressions

A

Admin • 831.35K Points
Coach

Q. Consider the following snippet of JavaScript code:
Which one of the following statement is most suitable to check if the pattern matches with the sting "text".

Code:
var text ="testing: 1, 2, 3";// Sample text  
var pattern =/d+/g// Matches all instances of one or more digits.
  • (A) test(text)
  • (B) equals(pattern)
  • (C) test(pattern)
  • (D) text==pattern

A

Admin • 831.35K Points
Coach

Q. Which one of the following is used for the calling a function or a method in the JavaScript:

  • (A) Property Access Expression
  • (B) Functional expression
  • (C) Invocation expression
  • (D) Primary expression

A

Admin • 831.35K Points
Coach

Q. The "new Point(3,2)", is a kind of _______ expression

  • (A) Object Creation Expression
  • (B) Primary Expression
  • (C) Invocation Expression
  • (D) Constructor Calling Expression

A

Admin • 831.35K Points
Coach

Q. Which one of the following operator is used to check weather a specific property exists or not:

  • (A) Exists
  • (B) exist
  • (C) within
  • (D) in

A

Admin • 831.35K Points
Coach

Q. Which one of the following is an ternary operator:

  • (A) ?
  • (B) ;
  • (C) -
  • (D) +

A

Admin • 831.35K Points
Coach

Q. "An expression that can legally appear on the left side of an assignment expression." is a well known explanation for variables, properties of objects, and elements of arrays. They are called_____

  • (A) Properties
  • (B) Prototypes
  • (C) Definition
  • (D) Lvalue

A

Admin • 831.35K Points
Coach

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

Code:
function display1(option)  
{  
    return(option ?  "true" :  "false");  
}  
    bool ans=true;  
console.log(display1(ans));  
  • (A) False
  • (B) True
  • (C) Runtime error
  • (D) Compilation error