javascript-exam 0 votes, 0 avg 325 123456789101112131415 JavaScript Questions 1 / 15 1. What will be the output of the following code snippet? let sum = 0; const a = [1, 2, 3]; a.forEach(getSum); print(sum); function getSum(ele) { sum += ele; } A. 2 B. 1 C. 6 D. None of the above 2 / 15 2. How to stop an interval timer in Javascript? A. clearInterval B. clearTimer C. interavlOver D. None of the above 3 / 15 3. What will be the output of the following JavaScript code? function printArray(a) { var len = a.length, i = 0; if (len == 0) console.log("Empty Array"); else { // do-while loop in javascript do { console.log(a[i]); } while (++i < len); } } A. Prints “Empty Array” B. Prints 0 to the length of the array C. Prints the numbers in the array in order D. Prints the numbers in the array in the reverse order 4 / 15 4. In JavaScript, what is a block of statement? A. Conditional block B. block that combines a number of statements into a single compound statement C. both conditional block and a single statement D. block that contains a single statement 5 / 15 5. What will be the output of the following JavaScript code with a p tag with id=demo? function myFunction() { document.getElementById("demo").innerHTML = Math.atan2(8, 4); } A. 1 B. 1.01 C. 1.05 D. 1.1 6 / 15 6. in javascript "===" operator defines what? A. Non-identical B. is equal to and is of the different types C. is equal to and is of the same type D. is equal 7 / 15 7. Which is the correct syntax for the function definition? A. return_type function function_name(parameter1, parameter2, ...) { /*Function's body*/ } B. function function_name(parameter1, parameter2, ...) { /*Function's body*/ } C. return_type function_name(parameter1, parameter2, ...) { /*Function's body*/ } D. function function_name(parameter1, parameter2, ...) as return_type { /*Function's body*/ } 8 / 15 8. Which JavaScript statements when embedded in an HTML page can respond to user events such as mouse clicks, form input and page navigation A. Native B. Server-Side C. Local D. Client-Side 9 / 15 9. Which property references the DOM object that dispatched an event? A. self B. object C. target D. source 10 / 15 10. If A is the superclass and B is the subclass, then subclass inheriting the superclass can be represented as _________ A. B=inherit(A); B. B=A.inherit(); C. B.prototype=inherit(A); D. B.prototype=inherit(A.prototype); 11 / 15 11. Which of the following is not considered as an error in javascript? A. syntax error B. missing of semicolon C. division by zero D. missing of bracket 12 / 15 12. Among the given statements, which statement defines closures in JavaScript? A. JavaScript is a function that is enclosed with references to its inner function scope B. JavaScript is a function that is enclosed with references to its lexical environment C. JavaScript is a function that is enclosed with the object to its inner function scope D. None of the mentioned 13 / 15 13. Which is the correct syntax to call an external JavaScript file in the current HTML document? A. <script src="jsfile.js"></script> B. <script href=" jsfile.js"></script> C. <import src=" jsfile.js"></import> D. <script link=" jsfile.js"></script> 14 / 15 14. Which collection object allows unique value to be inserted only once? A. Object B. Set C. Array D. Map 15 / 15 15. Why JavaScript Engine is needed? A. Both Compiling & Interpreting the JavaScript B. Parsing the javascript C. Interpreting the JavaScript D. Compiling the JavaScript Your score is LinkedIn Facebook Twitter VKontakte 0% Restart quiz