JavaScript Questions

0 votes, 0 avg
125

JavaScript Questions

1 / 15

1. Which handler is triggered when the content of the document in the window is stable and ready for manipulation?

2 / 15

2.  Why event handlers is needed in JS?

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;
}

4 / 15

4. Arrays in JavaScript are defined by which of the following statements?

5 / 15

5. JavaScript objects are written with _____.

6 / 15

6. JavaScript code can be written in ____.

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);

8 / 15

8. Which property is used to define the HTML content to an HTML element with a specific id?

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);

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);

11 / 15

11.  Which is the function that calls another function after a time interval?

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; 
 }

13 / 15

13. Arrays in JavaScript are defined by which of the following statements?

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;
}

15 / 15

15. Among the given statements, which statement defines closures in JavaScript?