JavaScript MCQs with answers Page - 29

Here, you will find a collection of MCQ questions on JavaScript. Go through these questions to enhance your preparation for upcoming examinations and interviews.

To check the correct answer, simply click the View Answer button provided for each question.

Have your own questions to contribute? Click the button below to share your MCQs with others!

+ Add Question

A

Admin • 833K Points
Coach

Q. Which one of the following is the correct output for the given JavaScript code?

Code:
    var a=0;  
    var b =0;  
    while (a <3)  
    {  
        a++;  
        b += a;  
        console.log(b);  
    }  
  • (A) 136
  • (B) 123
  • (C) 013
  • (D) 01

A

Admin • 833K Points
Coach

Q. Which of the following options would be the correct output for the given JavaScript code?

Code:
    var size=5;  
    var x=5;  
    var size=4;  
    for(var j=size;j>=0;j--)  
    {  
        console.log(x);  
        xx=x-2;  
    }  
  • (A) 5321
  • (B) 5555
  • (C) 531-1-3
  • (D) 531

A

Admin • 833K Points
Coach

Q. Which of the following options would be the correct output for the given JavaScript code?

Code:
var x=0;  
for(x;x<10;x++);  
console.log(x); 
  • (A) 10
  • (B) 4
  • (C) 5
  • (D) Error

A

Admin • 833K Points
Coach

Q. Consider the following piece of JavaScript code:
What is the role of the "debugger" statement?

Code:
<script>  
  
function fun(0){  
    if(0===undefined)  
        debugger;  
      
}  
  
</script> 
  • (A) It will debug the error in that statement
  • (B) It is kind of keyword which is used to debug the entire program at once
  • (C) It will do nothing, although it is a breakpoint
  • (D) All of the above

A

Admin • 833K Points
Coach

Q. Which one of the following is the correct output for the given JavaScript code?

Code:
    const obj ={prop:12};  
    Object.preventExtensions(obj);  
    console.log(Object.isExtensible(obj));  
  • (A) 12
  • (B) Error
  • (C) True
  • (D) False

A

Admin • 833K Points
Coach

Q. Which one of the following is the correct output for the given JavaScript code?

Code:
    const object1 ={  
      property1:20  
    };  
    console.log(Object.is(object1));  
  • (A) False
  • (B) true
  • (C) 20
  • (D) error

A

Admin • 833K Points
Coach

Q. A collection of elements of the same data type which may either in order or not, is called _____.

  • (A) String
  • (B) Array
  • (C) Serialized Object
  • (D) Object

A

Admin • 833K Points
Coach

Q. JavaScript is invented by

  • (A) Helsinki, Linus
  • (B) W3 Group
  • (C) Brendan Eich
  • (D) James Gosling

A

Admin • 833K Points
Coach

Q. JavaScript was invented at _______ Lab.

  • (A) AT&T Bell LAb
  • (B) Google Lab
  • (C) Sun Microsystem
  • (D) Netscape

A

Admin • 833K Points
Coach

Q. Variable can hold ________ value at a time.

  • (A) Multiple
  • (B) Single
  • (C) Double
  • (D) None of these

Add MCQ in this Category

If you want to share an MCQ question in this category, it's a great idea! It will be helpful for many other students using this website.

Share Your MCQ