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
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
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
Explanation: ’===’ sign is used for comparing the type of values. The result is true if the constructor property specifies the class.
4. How many static methods does a Date object have?
a) 3
b) 5
c) 4
d) 2
View Answer
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
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?
<script> function getAvg(){ var avg = 0; for(var x = 0; x < 200; x++){ avg += x; } return(avg/200); }
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
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
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
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
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
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.
- Get Free Certificate of Merit in JavaScript
- Participate in JavaScript Certification Contest
- Become a Top Ranker in JavaScript
- Take JavaScript Tests
- Chapterwise Practice Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
- Chapterwise Mock Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
- Buy Programming Books
- Practice MCA MCQs
- Practice Programming MCQs
- Apply for Information Technology Internship
- Buy JavaScript Books