Javascript - Quiz - Jan 2016

Beschreibung

Javascript Quiz for emids participants
arunram.krish
Quiz von arunram.krish, aktualisiert more than 1 year ago
arunram.krish
Erstellt von arunram.krish vor fast 9 Jahre
438
2

Zusammenfassung der Ressource

Frage 1

Frage
What are the values that evaluate to false when used in a Boolean expression?
Antworten
  • Only null
  • Only undefined
  • Only “”
  • Only NaN
  • All of the above

Frage 2

Frage
Which of the following statements are TRUE?
Antworten
  • When a variable that is not declared is used it returns “undefined”
  • When a variable that is not declared is used it throws ReferenceError
  • A function that is defined below in the later part of the script can be invoked / referred
  • A variable that is not assigned any value returns “undefined”

Frage 3

Frage
What are the primitive types in Javascript?
Antworten
  • Int, float, double, char, Boolean
  • Int, float, double, char, String, Boolean
  • Number, String, Boolean
  • Number, char, String, Boolean

Frage 4

Frage
How do you create an Object with a prototype object assigned to variable “proto”?
Antworten
  • var myObject = new Object(proto);
  • var myObject = new Object(); myObject.prototype = proto;
  • var myObject = Object.create(proto);
  • var myObject[“prototype”] = proto;

Frage 5

Frage
How to create a Javascript array?
Antworten
  • Only var myArray = new Array();
  • Only var myArray = [];
  • var myArray[] = new Object();
  • Both a & b

Frage 6

Frage
How 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?
Antworten
  • function SubClass() { super(); }
  • function SubClass() { ParentClass(); }
  • function SubClass() { new ParentClass(); }
  • function SubClass() { ParentClass.apply(this, arguments); }
  • All of the above

Frage 7

Frage
How do you use function to create a singleton object?
Antworten
  • var mySingleton = function() { function SingletonClass() { } return new SingletonClass(); };
  • b. var mySingleton = (function() { function SingletonClass() { } return new SingletonClass(); })();
  • var mySingleton = {};
  • It is not possible to create a singleton object using function

Frage 8

Frage
What is a Closure?
Antworten
  • A special scope variable assigned to function that holds states / variables that was accessible at the time of defining this inner function
  • Closure is a property of function that needs to be explicitly assigned within the body of function
  • Closure is a global function along with global variables
  • Closure is an inner function along with global variables

Frage 9

Frage
How do you invoke a callback function within a loop with loop index variable as argument after 500 milliseconds?
Antworten
  • function invokeCallback(callback) { for(var i=0;i<5;i++) { setTimeout(callback(i), 500); } }
  • function invokeCallback(callback) { for(var i=0;i<5;i++) { setTimeout(function() {callback(i)}, 500); } }
  • function invokeCallback(callback) { function invoker(i) { return function() { callback(i); } } for(var i=0;i<5;i++) { setTimeout(invoker(), 500); } }
  • None of the above

Frage 10

Frage
How do you add a function “removeDuplicates” (already defined with this name) accessible from all Array objects?
Antworten
  • Array.removeDuplicates = removeDuplicates;
  • Array.prototype.removeDuplicates = removeDuplicates
  • var myArray = new Array() { this.removeDuplicates = removeDuplicates; }
  • Array is a predefined type in javascript. It cannot be modified.

Frage 11

Frage
How does Javascript object inherit properties and methods defined in ancestor classes?
Antworten
  • Through constructor inheritance
  • Using extends keyword
  • Through prototype chaining
  • There is no automatic support in Javascript. Properties and behaviors need to be explicitly added

Frage 12

Frage
What is the difference between “!=” and “!==”?
Antworten
  • “!==” will not check for null or undefined or “” while “!=” checks
  • “!=” does not convert type while “!==” does convert type
  • “!==” does not do type coercion while “!= does type coercion
  • Both operators are same

Frage 13

Frage
How do you pass JSON data as part of HTTP POST request body in AJAX request?
Antworten
  • xhr.send(JSON.stringify(myJsonObject));
  • xhr.open(‘post’, myUrl, JSON.stringify(myJsonObject));
  • xhr.open(JSON.stringify(myJsonObject));
  • xhr.open(‘post’, myUrl + “?” + JSON.stringify(myJsonObject));

Frage 14

Frage
How do you create a “div” element with id “childDiv” and append it to parent div with id “parentDiv” using DOM API?
Antworten
  • var childDiv = window.createElement(“div”); window.getElementById(“parentDiv”).appendChild(childDiv);
  • var childDiv = document.newElement(“div”); document.getElementById(“parentDiv”).appendChild(childDiv);
  • var childDiv = document.createElement(“<div id=”childDiv”); window.getElementById(“parentDiv”).appendChild(childDiv);
  • var childDiv = document.createElement(“div”); childDiv.setAttribute(“id”, “childDiv”); document.getElementById(“parentDiv”).appendChild(childDiv);

Frage 15

Frage
Choose the best practices that need to be adopted in production environment to improve the performance?
Antworten
  • Keep Javascript files separate and download them individually
  • Concatenate multiple javascript files into single javascript file and refer to this javascript in the script tag
  • Use descriptive variable names and detailed comments
  • Minify javascript to reduce the overall size of Javascript file downloaded by browser
  • Use CDN site over local Javascript files
Zusammenfassung anzeigen Zusammenfassung ausblenden

ähnlicher Inhalt

Computing Hardware - CPU and Memory
ollietablet123
SFDC App Builder 2
Parker Webb-Mitchell
Intake7 BIM L1
Stanley Chia
Data Types
Jacob Sedore
Software Processes
Nurul Aiman Abdu
Design Patterns
Erica Solum
CCNA Answers – CCNA Exam
Abdul Demir
Abstraction
Shannon Anderson-Rush
Spyware
Sam2
HTTPS explained with Carrier Pigeons
Shannon Anderson-Rush
Translations and transformations of functions
Christine Laurich