JavaScript Questions & Answers – Comparison of Core JavaScript versus Frameworks – II

This set of JavaScript Questions and Answers for Campus interviews focuses on “Comparison of Core JavaScript versus Frameworks – II”.

1. Which of the following is not a JavaScript framework?
a) Rico
b) Prototype
c) Joco
d) DoJo
View Answer

Answer: d
Explanation: Dojo Toolkit is an open source modular JavaScript library (or more specifically JavaScript toolkit) designed to ease the rapid development of cross-platform, JavaScript/Ajax-based applications and web sites. Rico was an open-source JavaScript library for developing rich internet applications with Ajax.

2. What is the purpose of the Math method toSource()?
a) Returns the string “Math”
b) Sends the source to the Math Library
c) Returns the value of the object
d) Returns an integer value
View Answer

Answer: a
Explanation: The method Math.toSource() returns the string “Math”. But this method does not work with many browsers like IE. The toSource() method returns a string representing the source code of the object.

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

var o = new F();
o.constructor === F

a) false
b) true
c) 0
d) 1
View Answer

Answer: b
Explanation: ’===’ sign is used for comparing the type of values. The result is true if the constructor property specifies the class.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!

4. How many static methods does a Date object have?
a) 3
b) 5
c) 4
d) 2
View Answer

Answer: d
Explanation: Date objects are created with the new Date() constructor. The Date object defines two static methods namely Date.parse() and Date.UTC().

5. Which of the following are static methods in JavaScript?
a) Date.parse()
b) Date.UTC()
c) Both Date.parse() and Date.UTC()
d) Date.clear()
View Answer

Answer: c
Explanation: Date objects are created with the new Date() constructor. Date.parse() parses a string representation of a date and time and returns the internal millisecond representation of that date. Date.UTC() Returns the millisecond representation of the specified UTC date and time.

6. What will be the work of the getAvg in the following JavaScript function?

function getAvg(){
var avg = 0;
for(var x = 0; x < 200; x++){
avg += x;

a) Multiples values from 0 to 200
b) Adds values from 0 to 200
c) Simply traverses with no operation
d) Find the average of 199 numbers
View Answer

Answer: d
Explanation: For loop is used in the above code for adding the numbers. The above code performs the average calculation of numbers from 0 to 199.

7. If we have an object r and want to know if it is a Range object, we can write ______________
a) r typeof Range
b) r is Range
c) r equals Range
d) r instanceof Range
View Answer

Answer: d
Explanation: To know the range object r instanceof range is used. The r instanceof Range returns true if r inherits from Range.prototype. The instanceof operator does not actually check whether r was initialized by the Range constructor.

8. What is the property to access the first child of a node?
a) timestamp.Child1
b) timestamp.Child(1)
c) timestamp.Child(0)
d) timestamp.firstChild
View Answer

Answer: d
Explanation: The firstChild property returns the first child node of the specified node, as a Node object. The first child of a node can be accessed using the firstChild property.

9. Which of the following is not an object?
a) Element
b) Location
c) Position
d) Window
View Answer

Answer: c
Explanation: The window object represents an open window in a browser. There is no object called Position.

10. What is the code snippet to change the class and let the stylesheet specify the details?
a) timestamp.className = “highlight”;
b) timestamp.className = “change”;
c) timestamp.className = “specify”;
d) timestamp.className = “move”;
View Answer

Answer: a
Explanation: “typename” is a keyword in the C++ programming language used when writing templates. The above code snippet changes the class and lets the stylesheet specify the details.

Sanfoundry Global Education & Learning Series – Javascript Programming.

To practice all areas of JavaScript for Campus Interviews, here is complete set of 1000+ Multiple Choice Questions and Answers on Javascript.

Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.