JavaScript Questions March 14, 2023 | No Comments 0 votes, 0 avg 125 123456789101112131415 JavaScript Questions 1 / 15 1. Which handler is triggered when the content of the document in the window is stable and ready for manipulation? A. onload B. manipulate C. create D. onCreate 2 / 15 2. Why event handlers is needed in JS? A. Allows JavaScript code to alter the behaviour of windows. B. Adds innerHTML page to the code C. Change the server location D. Performs handling of exceptions and occurrences 3 / 15 3. 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 4 / 15 4. Arrays in JavaScript are defined by which of the following statements? A. It is an ordered list of values B. It is an ordered list of objects C. It is an ordered list of string D. It is an ordered list of functions 5 / 15 5. JavaScript objects are written with _____. A. round brackets () B. curly brackets {} C. double quotes "" D. square brackets [] 6 / 15 6. JavaScript code can be written in ____. A. JavaScript file (.js file) B. HTML document directly C. JavaScript file and in HTML document directly D. In style sheets (.css file) 7 / 15 7. What will be the output of the following code snippet? var x=12; var y=8; var res=eval("x+y"); document.write(res); A. 20 B. x+y C. 128 D. None of the above 8 / 15 8. Which property is used to define the HTML content to an HTML element with a specific id? A. innerText B. innerContent C. elementText D. innerHTML 9 / 15 9. 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 10 / 15 10. What is the result in the console of running the code shown? var start = 1; function setEnd() { var end = 10; } setEnd(); console.log(end); A. 10 B. 1 C. ReferenceError D. None of the above 11 / 15 11. Which is the function that calls another function after a time interval? A. setTimeout() B. setTime() C. callafter() D. timeSet() 12 / 15 12. 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 13 / 15 13. Arrays in JavaScript are defined by which of the following statements? A. It is an ordered list of values B. It is an ordered list of objects C. It is an ordered list of string D. It is an ordered list of functions 14 / 15 14. What will be the function of the following JavaScript program? var scope = "js scope"; function checkscope() { var scope = "javascript scope"; function f() { return scope; } return f; } A. Returns the value in scope B. Returns value null C. Shows an error message D. Returns exception 15 / 15 15. 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 Your score is LinkedIn Facebook Twitter VKontakte 0% Restart quiz Questions, Quiz