JavaScript MCQ Quiz - Objective Question with Answer for JavaScript - Download Free PDF
Last updated on Feb 13, 2024
Latest JavaScript MCQ Objective Questions
JavaScript Question 1:
If he had asked me, ________ him.
Answer (Detailed Solution Below)
JavaScript Question 1 Detailed Solution
The correct answer is "I would have helped".
Key Points
- The given sentence is conditional and describes a hypothetical situation in the past.
- It follows the 'third conditional' pattern, which is used to express situations that could have happened in the past but didn't.
- The third conditional is formed with 'if' + past perfect in the condition clause, and 'would have' + past participle in the result clause.
- Therefore, the correct answer is "Option 3".
Additional Information
- 'I would help' and 'I will help' express future actions which is not consistent with the past scenario described in the sentence.
- 'I shall have helped' is an example of future perfect tense and is used to talk about actions that will finish in the future. This does not fit the past hypothetical nature of the situation.
JavaScript Question 2:
Which of the following is not a built-in module in Node.js?
Answer (Detailed Solution Below)
JavaScript Question 2 Detailed Solution
Node.js
- Node.js is a platform that allows developers to write server-side JavaScript applications using the same language and runtime environment as front-end web development.
- Node.js comes with several built-in modules that provide functionality for common tasks, such as working with files (fs), creating HTTP servers (http), and managing file paths (path).
- These built-in modules can be used in Node.js applications without any additional installation.
mysql module
- The mysql module, on the other hand, is not a built-in module in Node.js.
- It is a third-party module that provides a way for Node.js applications to communicate with MySQL databases.
- In order to use the mysql module, it must be installed separately via the npm (Node Package Manager) tool, which is included with Node.js.
- This can be done by running the command 'npm install mysql' in a terminal or command prompt window.
Hence, the correct answer is option 3.
JavaScript Question 3:
A 2D array having a different number of elements in each row is known as ________.
Answer (Detailed Solution Below)
JavaScript Question 3 Detailed Solution
Spares - There is no such term related to arrays in programming.
Danes - There is no such term related to arrays in programming.
Regular - A regular array is a 2D array where each row has the same number of elements.
Irregular - An irregular array, also known as a jagged array, is a 2D array where each row can have a different number of elements. This type of array can be useful in situations where you have data that does not fit neatly into a rectangular shape, such as when dealing with data of varying lengths or when representing a hierarchical structure. In C++, an irregular array can be implemented as an array of arrays, where each sub-array can have a different size.
- A 2D array having a different number of elements in each row is known as an "irregular" array.
JavaScript Question 4:
In JavaScript "= = =" operator defines what?
Answer (Detailed Solution Below)
JavaScript Question 4 Detailed Solution
The correct answer is option 3.
Concept:
- In JavaScript "= = =" operator defines Is identical (is equal to and is of the same type).
- The === operator in javascript compares the equality of two operands with type.
- If both type and value are equal, the condition is true; otherwise, it is false.
- In javascript, the equality operator is used to check if two values are equal. In javascript, the comparison is done with the == and === operators.
- The fundamental difference between the == and === operators in javascript is that the == operator converts the operands' types before comparing them, whereas the === operator compares the operands' values as well as their data types.
- The type conversion of the operand is the major difference between == and === in Javascript.
Syntax for equality:
x === y
Example:
let a = 10;
let b = '10';
let c = 10;
console.log(a===b); //output: false;
console.log(a===c); //output: true;
Syntax for equality:
x == y
Example:
let a = 10;
let b = '10';
let c = 10;
console.log(a===b); //output: true;
console.log(a===c); //output: true;
Hence the correct answer Is identical (is equal to and is of the same type).
JavaScript Question 5:
Which one of the following is not considered as an error in JS
Answer (Detailed Solution Below)
JavaScript Question 5 Detailed Solution
Concept:
Division of any integer by zero is not an error in the JavaScript. It just prints the infinity as a result. However, there is an exception in JavaScript, dividing zero with zero will not have any defined number/value so, the result of this specific operation is a special value "Not a Number" (or NaN) and printed as NaN.
Top JavaScript MCQ Objective Questions
_______ among the following is a Language of JavaScript.
Answer (Detailed Solution Below)
JavaScript Question 6 Detailed Solution
Download Solution PDFThe correct answer is text/JavaScript.
Key Points
- The programming language JavaScript is one of the foundational elements of the World Wide Web.
- JavaScript is an ECMAScript-compliant high-level, frequently just-in-time compiled language.
- It features first-class functions, prototype-based object orientation, and dynamic typing.
- It supports event-driven, functional, and imperative programming paradigms and is a multi-paradigm.
- It offers application programming interfaces (APIs) for using the Document Object Model, regular expressions, dates, and standard data structures.
Additional Information
- ECMAScript:
- A JavaScript standard called ECMAScript was created to guarantee browser compatibility for web pages.
- VBScript:
- Microsoft created VBScript, an Active Scripting language based on Visual Basic.
Which state has been linked with Himachal Pradesh under 'Ek Bharat Shreshtha Bharat' program to promote national unity through mutual understanding as on 30 June 2020?
Answer (Detailed Solution Below)
JavaScript Question 7 Detailed Solution
Download Solution PDFThe correct answer is Kerala.
- Kerala has linked with Himachal Pradesh under Ek Bharat Shreshtha Bharat.
- The program aims to actively enhance interaction between people of diverse cultures living in different States and UT's in India.
- This is a part of Ek Bharat Shrestha Bharat activities, Ministry of Tourism.
Important Points
State | Paired State/UTs |
Goa | Jharkhand |
Gujarat | Chhattisgarh |
Karnataka | Uttarakhand |
Key Points
- The mission of Ek Bharat Shreshtha Bharat:
- To Celebrate the Unity in the Diversity of our Nation and to maintain and strengthen the fabric of traditionally existing emotional bonds between the people of our Country.
- To promote the spirit of national integration through a deep and structured engagement between all Indian States and Union Territories.
- To Showcase the rich heritage and culture, customs, and traditions of either State for enabling people to understand and appreciate the diversity that is India.
- To establish long-term engagements and, to create an environment that promotes learning between States/UTs by sharing best practices and experiences.
If he had asked me, ________ him.
Answer (Detailed Solution Below)
JavaScript Question 8 Detailed Solution
Download Solution PDFThe correct answer is "I would have helped".
Key Points
- The given sentence is conditional and describes a hypothetical situation in the past.
- It follows the 'third conditional' pattern, which is used to express situations that could have happened in the past but didn't.
- The third conditional is formed with 'if' + past perfect in the condition clause, and 'would have' + past participle in the result clause.
- Therefore, the correct answer is "Option 3".
Additional Information
- 'I would help' and 'I will help' express future actions which is not consistent with the past scenario described in the sentence.
- 'I shall have helped' is an example of future perfect tense and is used to talk about actions that will finish in the future. This does not fit the past hypothetical nature of the situation.
The correct syntax to write "Hi There" in Javascript is
Answer (Detailed Solution Below)
JavaScript Question 9 Detailed Solution
Download Solution PDFThe correct answer is “option 2”.
Concept:
- The write() method writes HTML expressions or JavaScript code to a document
- In javascript, document.write(" ") at client side and response.write on server side
Explanation:
All options 1, 3 & 4 are having the wrong syntax.
Hence, the correct syntax is response.write("Hi There").
JavaScript Question 10:
_______ among the following is a Language of JavaScript.
Answer (Detailed Solution Below)
JavaScript Question 10 Detailed Solution
The correct answer is text/JavaScript.
Key Points
- The programming language JavaScript is one of the foundational elements of the World Wide Web.
- JavaScript is an ECMAScript-compliant high-level, frequently just-in-time compiled language.
- It features first-class functions, prototype-based object orientation, and dynamic typing.
- It supports event-driven, functional, and imperative programming paradigms and is a multi-paradigm.
- It offers application programming interfaces (APIs) for using the Document Object Model, regular expressions, dates, and standard data structures.
Additional Information
- ECMAScript:
- A JavaScript standard called ECMAScript was created to guarantee browser compatibility for web pages.
- VBScript:
- Microsoft created VBScript, an Active Scripting language based on Visual Basic.
JavaScript Question 11:
Which state has been linked with Himachal Pradesh under 'Ek Bharat Shreshtha Bharat' program to promote national unity through mutual understanding as on 30 June 2020?
Answer (Detailed Solution Below)
JavaScript Question 11 Detailed Solution
The correct answer is Kerala.
- Kerala has linked with Himachal Pradesh under Ek Bharat Shreshtha Bharat.
- The program aims to actively enhance interaction between people of diverse cultures living in different States and UT's in India.
- This is a part of Ek Bharat Shrestha Bharat activities, Ministry of Tourism.
Important Points
State | Paired State/UTs |
Goa | Jharkhand |
Gujarat | Chhattisgarh |
Karnataka | Uttarakhand |
Key Points
- The mission of Ek Bharat Shreshtha Bharat:
- To Celebrate the Unity in the Diversity of our Nation and to maintain and strengthen the fabric of traditionally existing emotional bonds between the people of our Country.
- To promote the spirit of national integration through a deep and structured engagement between all Indian States and Union Territories.
- To Showcase the rich heritage and culture, customs, and traditions of either State for enabling people to understand and appreciate the diversity that is India.
- To establish long-term engagements and, to create an environment that promotes learning between States/UTs by sharing best practices and experiences.
JavaScript Question 12:
JavaScript is only object oriented.
Answer (Detailed Solution Below)
JavaScript Question 12 Detailed Solution
The correct answer is option 1 i.e. FALSE
Key PointsJavaScript is mainly known as an object-oriented scripting language, but it also supports other programming paradigms such as procedural and functional programming. Therefore, saying that JavaScript is only object oriented is false.
JavaScript Question 13:
Any time you include JavaScript verbiage in HTML document, you must enclose those lines inside a ______ tag pair.
Answer (Detailed Solution Below)
JavaScript Question 13 Detailed Solution
Answer: Option 3
Explanation:
Option 1: < Div > and < / Div >
This is not correct. as this pair used to create a division in an HTML page/document.
Option 2: < Body > and < / Body >
This is not correct. as body tag used to define the body of HTML page.
Option 3:
- Daily Live Classes
- 250+ Test series
- Study Material & PDF
- Quizzes With Detailed Analytics
- + More Benefits