JavaScript Multiple Choice Questions Set-1

Name
Email
1. Javascript is an _______ language?

2. Which of the following keywords is used to define a variable in Javascript?

3. Which of the following methods is used to access HTML elements using Javascript?

4. Upon encountering empty statements, what does the Javascript Interpreter do?

5. Which of the following methods can be used to display data in some form using Javascript?

6. What will be the output of the following code snippet?


a = 5 + "9";
document.write(a);

7. What will be the output of the following code snippet?

<script type="text/javascript" language="javascript">
var a = "CodeScript";
var result = a.substring(2, 4);
document.write(result);

8. What will be the output of the following code snippet?



var x=12;
var y=8;
var res=eval("x+y");
document.write(res);

9. What keyword is used to check whether a given property is valid or not?

10. What is the use of the tag in Javascript?

11. What will be the output of the following code snippet?

(function(){
setTimeout(()=> console.log(1),2000);
console.log(2);
setTimeout(()=> console.log(3),0);
console.log(4);
})();

12. What will be the output of the following code snippet?

(function(a){
return (function(){
console.log(a);
a = 6;
})()
})(21);

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

14. What will be the output for the following code snippet?



function Func()
{
document.getElementById("example").innerHTML=Math.sqrt(81);
}

15. Which function is used to serialize an object into a JSON string in Javascript?

Leave a Reply