JavaScript Questions March 14, 2023 | No Comments 0 votes, 0 avg 608 123456789101112131415 JavaScript Questions 1 / 15 1. 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 2 / 15 2. 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 3 / 15 3. What will be the output of the following JavaScript code? const curr = new Date(); document.write(curr); A. Tue Dec 21 2021 13:04:36 GMT+0530 B. Tue Dec 21 2021 13:04:36 (India Standard Time) C. Tue Dec 21 2021 13:04:36::00::01 GMT+0530 (India Standard Time) D. Tue Dec 21 2021 13:04:36 GMT+0530 (India Standard Time) 4 / 15 4. 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 5 / 15 5. Which collection object allows unique value to be inserted only once? A. Object B. Set C. Array D. Map 6 / 15 6. 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 7 / 15 7. 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] 8 / 15 8. What is the code for getting the current time? A. now = new Date(); B. var now = new Date(); C. var now = Date(); D. var now = new Date(current); 9 / 15 9. Which of the following can be implemented using animation? A. Fireworks B. Fade Effect C. Roll-in or Roll-out D. All of the mentioned 10 / 15 10. 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) 11 / 15 11. 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*/ } 12 / 15 12. Which JavaScript method is used to write HTML output? A. document.write() B. document.output() C. console.log() D. document.writeHTML() 13 / 15 13. Which statement creates a new object using the Person constructor? A. var student = construct Person; B. var student = new Person(); C. var student = Person(); D. var student = construct Person(); 14 / 15 14. What will be the output of the following JavaScript code? let cars = ['Honda', 'Hyundai']; cars.push('Mahindra'); document.write(typeof cars + " " + cars); A. array Honda,Hyundai,Mahindra B. string Honda,Hyundai,Mahindra C. object Honda,Hyundai,Mahindra D. object "Honda", "Hyundai", "Mahindra" 15 / 15 15. What does the ‘toLocateString()’ method do in JS? A. Returns a localised object representation B. Returns a localised string representation of an object C. Returns parsed string D. None of the above Your score is LinkedIn Facebook VKontakte 0% Restart quiz By WordPress Quiz plugin Questions, Quiz