javascript-exam 0 votes, 0 avg 288 123456789101112131415 JavaScript Questions 1 / 15 1. What will be the output of the following JavaScript code? var cars = ["Honda","Hyundai","Mahindra"]; var result = cars.shift(); document.writeln("Result: ", cars); A. Result: Honda,Hyundai,Mahindra B. Result: Honda C. Result: Hyundai,Mahindra D. Result: Honda,Mahindra 2 / 15 2. Which of the following methods is used to access HTML elements using Javascript? A. getElementById() B. getElementByClassName() C. Both A and B D. None of the above 3 / 15 3. Will the following JavaScript code work? var js = (function(x) {return x*x;}(10)); A. Exception will be thrown B. Memory leak C. Error D. Yes 4 / 15 4. What will be the output of the following JavaScript code? const arr = [10, 20, 30]; let result = 0; arr.forEach(myFunction); document.write("Result: " , result) function myFunction(value, index, array) { result += value; } A. Result: 60 B. Result: 102030 C. Result: 10,20,30 D. ValueError 5 / 15 5. 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 6 / 15 6. The process in which an object or data structure is translated into a format suitable for transferral over a network, or storage is called? A. Object Serialization B. Object Encapsulation C. Object Inheritance D. None of the above 7 / 15 7. Which JavaScript method is used to create a new array with array elements that passes a test? A. forEach() B. map() C. forMap() D. filter() 8 / 15 8. What will be the output of the following code snippet? var a = 1; var b = 0; while (a <= 3) { a++; b += a * 2; print(b); } A. 1 2 3 B. 4 10 18 C. 1 4 7 D. None of the above 9 / 15 9. What will be the result or type of error if p is not defined in the following JavaScript code snippet? console.log(p) A. Value not found Error B. Reference Error C. Null D. Zero 10 / 15 10. What will be the output of the following JavaScript code? const prototype1 = {}; const object1 = Object.create(prototype1); console.log(Object.getPrototypeOf(object1) === prototype1); A. True B. error C. zero D. False 11 / 15 11. When an operator’s value is NULL, the typeof returned by the unary operator is: A. Boolean B. Object C. Undefined D. Integer 12 / 15 12. 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 13 / 15 13. Which one of the following is correct output for the following given JavaScript code if there is a p tag with id=demo ? functionourFunction() { document.getElementById("demo").innerHTML=Math.abs(-7.25); } A. 7 B. -7.25 C. -7 D. 25 14 / 15 14. What is the prototype represents in the following JavaScript code snippet? function javascript() {}; A. Not valid B. Protoype of a function C. Function javascript D. A custom constructor 15 / 15 15. What is the main difference between var and let keywords in JavaScript? A. var defines a variable while let defines a constant B. var defined function scoped variable while let define block scoped variable C. he value of a variable declared with var can be changed while the value of a variable declared with let cannot be changed D. all of the above Your score is LinkedIn Facebook Twitter VKontakte 0% Restart quiz