Test
Javascript - Quiz - Jan 2016
Este test tiene tiempo límite, así que se abre en el reproductor de siempre.
Preguntas del test (15)
1What are the values that evaluate to false when used in a Boolean expression?
- AOnly null
- BOnly undefined
- COnly “”
- DOnly NaN
- EAll of the above
2Which of the following statements are TRUE?
- AWhen a variable that is not declared is used it returns “undefined”
- BWhen a variable that is not declared is used it throws ReferenceError
- CA function that is defined below in the later part of the script can be invoked / referred
- DA variable that is not assigned any value returns “undefined”
3What are the primitive types in Javascript?
- AInt, float, double, char, Boolean
- BInt, float, double, char, String, Boolean
- CNumber, String, Boolean
- DNumber, char, String, Boolean
4How do you create an Object with a prototype object assigned to variable “proto”?
- Avar myObject = new Object(proto);
- Bvar myObject = new Object();
myObject.prototype = proto; - Cvar myObject = Object.create(proto);
- Dvar myObject[“prototype”] = proto;
5How to create a Javascript array?
- AOnly var myArray = new Array();
- BOnly var myArray = [];
- Cvar myArray[] = new Object();
- DBoth a & b
6How do you invoke parent class’ constructor (by name ParentClass) from a sub class constructor (by name SubClass) to inherit properties defined in ParentClass in the new SubClass object?
- Afunction SubClass() { super(); }
- Bfunction SubClass() { ParentClass(); }
- Cfunction SubClass() { new ParentClass(); }
- Dfunction SubClass() { ParentClass.apply(this, arguments); }
- EAll of the above
7How do you use function to create a singleton object?
- Avar mySingleton = function() {
function SingletonClass() {
}
return new SingletonClass();
}; - Bb. var mySingleton = (function() {
function SingletonClass() {
}
return new SingletonClass();
})(); - Cvar mySingleton = {};
- DIt is not possible to create a singleton object using function
- Avar mySingleton = function() {
8What is a Closure?
- AA special scope variable assigned to function that holds states / variables that was accessible at the time of defining this inner function
- BClosure is a property of function that needs to be explicitly assigned within the body of function
- CClosure is a global function along with global variables
- DClosure is an inner function along with global variables
9How do you invoke a callback function within a loop with loop index variable as argument after 500 milliseconds?
- Afunction invokeCallback(callback) {
for(var i=0;i<5;i++) {
setTimeout(callback(i), 500);
}
} - Bfunction invokeCallback(callback) {
for(var i=0;i<5;i++) {
setTimeout(function() {callback(i)}, 500);
}
} - Cfunction invokeCallback(callback) {
function invoker(i) {
return function() { callback(i); }
}
for(var i=0;i<5;i++) {
setTimeout(invoker(), 500);
}
} - DNone of the above
- Afunction invokeCallback(callback) {
10How do you add a function “removeDuplicates” (already defined with this name) accessible from all Array objects?
- AArray.removeDuplicates = removeDuplicates;
- BArray.prototype.removeDuplicates = removeDuplicates
- Cvar myArray = new Array() {
this.removeDuplicates = removeDuplicates;
} - DArray is a predefined type in javascript. It cannot be modified.
11How does Javascript object inherit properties and methods defined in ancestor classes?
- AThrough constructor inheritance
- BUsing extends keyword
- CThrough prototype chaining
- DThere is no automatic support in Javascript. Properties and behaviors need to be explicitly added
12What is the difference between “!=” and “!==”?
- A“!==” will not check for null or undefined or “” while “!=” checks
- B“!=” does not convert type while “!==” does convert type
- C“!==” does not do type coercion while “!= does type coercion
- DBoth operators are same
13How do you pass JSON data as part of HTTP POST request body in AJAX request?
- Axhr.send(JSON.stringify(myJsonObject));
- Bxhr.open(‘post’, myUrl, JSON.stringify(myJsonObject));
- Cxhr.open(JSON.stringify(myJsonObject));
- Dxhr.open(‘post’, myUrl + “?” +
JSON.stringify(myJsonObject));
14How do you create a “div” element with id “childDiv” and append it to parent div with id “parentDiv” using DOM API?
- Avar childDiv = window.createElement(“div”);
window.getElementById(“parentDiv”).appendChild(childDiv); - Bvar childDiv = document.newElement(“div”);
document.getElementById(“parentDiv”).appendChild(childDiv); - Cvar childDiv = document.createElement(“<div
id=”childDiv”);
window.getElementById(“parentDiv”).appendChild(childDiv); - Dvar childDiv = document.createElement(“div”);
childDiv.setAttribute(“id”, “childDiv”);
document.getElementById(“parentDiv”).appendChild(childDiv);
- Avar childDiv = window.createElement(“div”);
15Choose the best practices that need to be adopted in production environment to improve the performance?
- AKeep Javascript files separate and download them individually
- BConcatenate multiple javascript files into single javascript file and refer to this javascript in the script tag
- CUse descriptive variable names and detailed comments
- DMinify javascript to reduce the overall size of Javascript file downloaded by browser
- EUse CDN site over local Javascript files
Información
- Descripción
- Javascript Quiz for emids participants
- Autor
- arunram.krish
- Idioma
- English
- Visitas
- 496
- Etiquetas
- Valoración
- 4,0 de 5 · 2 valoraciones Valora este test