JavaScript Questions March 14, 2023 | No Comments 0 votes, 0 avg 604 123456789101112131415 JavaScript Questions 1 / 15 1. 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 2 / 15 2. Which of the following methods can be used to display data in some form using Javascript? A. document.write() B. console.log() C. window.alert() D. all of the above 3 / 15 3. 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*/ } 4 / 15 4. What will be the output of the following code snippet? var a = "Scaler"; var result = a.substring(2, 4); document.write(result); A. al B. ale C. cal D. caler 5 / 15 5. What will be the output of the following code snippet? function solve(arr, rotations){ if(rotations == 0) return arr; for(let i = 0; i < rotations; i++){ let element = arr.pop(); arr.unshift(element); } return arr; } // solve([44, 1, 22, 111], 5); A. [111, 44, 1, 22] B. [44, 1, 22, 111] C. [111, 22, 1, 44] D. [1, 22, 111, 44] 6 / 15 6. 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 7 / 15 7. 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> 8 / 15 8. What does the Javascript “debugger” statement do? A. It will debugg all the errors in the program at runtime. B. It acts as a breakpoint in a program C. it will debugg error in the current statement if any 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. Which of the following is a valid function to truncate number of full minutes between two time stamps? A. this_month() function B. minutes_between() function C. hours_between() function D. weeks_between() function 11 / 15 11. Which of the following function of the String object returns the character in the string starting at the specified position via the specified number of characters? A. slice() B. split() C. substr() D. search() 12 / 15 12. 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 13 / 15 13. Which JavaScript method is used to access an HTML element by id? A. getElementByID() B. getElement(Id) C. getElementById(id) D. elementById(id) 14 / 15 14. Which of the following is correct about JavaScript? A. JavaScript is an Object-Based language B. JavaScript is Assembly-language C. JavaScript is an Object-Oriented language D. JavaScript is a High-level language 15 / 15 15. how can you write into HTML output using javascript? A. using innerHTML B. Using console.log() C. Using document.write() D. using window.alert() Your score is LinkedIn Facebook VKontakte 0% Restart quiz By WordPress Quiz plugin Questions, Quiz