Explore topic-wise MCQs in Javascript.

This section includes 114 Mcqs, each offering curated multiple-choice questions to sharpen your Javascript knowledge and support exam preparation. Choose a topic below to get started.

51.

*$_The ‘$’ present in the RegExp object is called a?

A. character
B. matcher
C. metacharacter
D. metadata
Answer» D. metadata
52.

*$_What does the subexpression /java(script)?/ result in ??

A. It matches “java” followed by the optional “script”
B. It matches “java” followed by any number of “script”
C. It matches “java” followed by a minimum of one “script”
D. None of the mentioned
Answer» B. It matches ‚Äö√Ñ√∫java‚Äö√Ñ√π followed by any number of ‚Äö√Ñ√∫script‚Äö√Ñ√π
53.

*$_The functions provide() and require() of Dojo toolkit and Google’s Closure library are used for?

A. declaring and loading modules
B. loading and declaring modules
C. declaring modules
D. none of the mentioned
Answer» B. loading and declaring modules
54.

*$_Modules that have more than one item in their API can?

A. Assign itself to a global variable
B. Invoke another module of the same kind
C. Return a namespace object
D. Invoke another module of the same kind
Answer» D. Invoke another module of the same kind
55.

*/*_Which method to use while working with XML fragments, instead of XML()??

A. XMLInterface()
B. XMLClass()
C. XMLList()
D. XMLArray()
Answer» D. XMLArray()
56.

*/*_Consider the following code snippetdata.sort(function(a,b),b-a);What does the above code do??

A. Sort in the alphabetical order
B. Sort in the chronological order
C. Sort in reverse alphabetical order
D. Sort in reverse numerical order
Answer» E.
57.

*/*_Consider the following code snippet[x,y]=[y,x];What is the result of the above code snippet??

A. Throws exception
B. Swap the value of the two variables
C. Flashes an error
D. Creates a new reference object
Answer» D. Creates a new reference object
58.

*/*_The meaning for Augmenting classes is that?

A. objects inherit prototype properties even in dynamic state
B. objects inherit prototype properties only in dynamic state
C. objects inherit prototype properties in static state
D. None of the mentioned
Answer» B. objects inherit prototype properties only in dynamic state
59.

_ The Crockford’s subset doesnot include which function in JavaScript?$?

A. eval()
B. coeval()
C. equal()
D. equivalent()
Answer» B. coeval()
60.

_ Why is the this keyword forbidden in JavaScript?$?

A. Highly memory consuming
B. Functions should access the global objects
C. Functions should not access the global objects
D. Very inefficient to use
Answer» D. Very inefficient to use
61.

_ The snippet that filters the filtered set is$?

A. var t=new FilteredSet(s, {function(s) {return !(x instanceof Set);});
B. var t=new FilteredSet{function(s) {return !(x instanceof Set);});
C. var t=new FilteredSet(s, {function(s) {return (x instanceof Set);});
D. var t=new FilteredSet(s, {function(s) {return x;});
Answer» B. var t=new FilteredSet{function(s) {return !(x instanceof Set);});
62.

_ Which are usually variables that are used internally in object methods and also are globally visible variables?$?

A. Object properties
B. Variable properties
C. Method properties
D. Internal properties
Answer» C. Method properties
63.

_ What can be done in order to avoid creation of global variables in JavaScript?$?

A. To use a method that defines all the variables
B. To use an object that has the reference to all the variables
C. To use an object as its namespace
D. To use global functions
Answer» D. To use global functions
64.

_ What will be the result when non greedy repetition is used on the pattern /a+?b/ ?$?

A. Matches the letter b preceded by the fewest number of a’s possible
B. Matches the letter b preceded by any number of a
C. Matches letter a preceded by letter b, in the stack order
D. None of the mentioned
Answer» B. Matches the letter b preceded by any number of a
65.

_ You can refresh the webpage in JavaScript by using$?

A. window.reload
B. location.reload
C. window.refresh
D. page.refresh
Answer» C. window.refresh
66.

_ The scope of a function is also called as$?

A. The function’s scope
B. Module function
C. Modulated function
D. Private function
Answer» C. Modulated function
67.

_ What is the return type of typeof for standard JavaScript objects?$?

A. xml
B. object
C. dom
D. html
Answer» C. dom
68.

_ Consider the following code snippetlet succ = function(x) x+1, yes = function() true, no = function() false;What convenience does the above code snippet provide?$?

A. Functional behaviour
B. Modular behaviour
C. No convenience
D. Shorthand expression
Answer» B. Modular behaviour
69.

_ Consider the following code snippetlet x=x+1;console.log(x);What will be the result for the above code snippet?$?

A. 0
B. Null
C. ReferenceError
D. NaN
Answer» E.
70.

_ Consider the following code snippetconst pi=3.14;var pi=4;console.log(pi);What will be the output for the above code snippet?$?

A. This will flash an error
B. Prints 4
C. Prints 3.14
D. Ambiguity
Answer» B. Prints 4
71.

__The basic difference between JavaScript and Java is__

A. There is no difference
B. Functions are considered as fields
C. Variables are specific
D. Functions are values, and there is no hard distinction between methods and fields
Answer» E.
72.

_What would be the result of the following statement in JavaScript using regular expression methods ?$?

A. Returns [“123″”456″”789”]
B. Returns [“123″,”456″,”789”]
C. Returns [1,2,3,4,5,6,7,8,9]
D. Throws an exception
Answer» C. Returns [1,2,3,4,5,6,7,8,9]
73.

_Which is the subset that is a secure container designed for the purpose of safely running untrusted JavaScript?$?

A. Sandbox
B. The Good Parts
C. Both Sandbox and Good Parts
D. None of the mentioned
Answer» B. The Good Parts
74.

_If A is the superclass and B is the subclass, then subclass inherting the superclass can be represented as$?

A. B=inherit(A);
B. B=A.inherit();
C. B.prototype=inherit(A);
D. B.prototype=inherit(A.prototype);
Answer» D. B.prototype=inherit(A.prototype);
75.

_The object whose properties are inherited by all instances of the class, and properties whose values are functions behaving like instance methods of the class, is$?

A. Instance object
B. Constructor object
C. Destructor object
D. Prototype object
Answer» E.
76.

_The properties() method is a$?

A. Enumerable method
B. Non-enumerable method
C. Operational method
D. None of the mentioned
Answer» C. Operational method
77.

_What does /[^(]* regular expression indicate ?$?

A. Match one or more characters that are not open paranthesis
B. Match zero or more characters that are open paranthesis
C. Match zero or more characters that are not open paranthesis
D. Match one or more characters that are open paranthesis
Answer» D. Match one or more characters that are open paranthesis
78.

_What is the procedure to add methods to HTMLElement so that they will be inherited by the objects that represent the HTML tags in the current document?$?

A. HTMLElement.prototype(…)
B. HTMLElement.prototype
C. HTML.addmethods()
D. HTML.elements(add)
Answer» C. HTML.addmethods()
79.

_Consider the following statementvar Set = sets.Set;var s = new Set(1,2,3);What could be the efficiency quotient of the above two statements ?$?

A. The programmer imports at once the frequently used values into the global namespace
B. There is no efficiency quotient, the programmer tries to make it inefficient
C. The programmer needs to import the Sets everytime he wants to use it
D. All of the mentioned
Answer» B. There is no efficiency quotient, the programmer tries to make it inefficient
80.

_When will the finally block be called?$?

A. When there is no exception
B. When the catch doesnot match
C. When there is exception
D. None of the mentioned
Answer» E.
81.

_Which method of the iterable object returns an iterator object for the collection?$?

A. iterator()
B. _iterator_()
C. _iteration_()
D. _return_iterator_()
Answer» C. _iteration_()
82.

_Consider the following code snippetconsole.log(p)If p is not defined, what would be the result or type of error?$?

A. Zero
B. Null
C. ReferenceError
D. ValueNotFoundError
Answer» D. ValueNotFoundError
83.

_Which is the subset that transforms web content into secure modules that can be safely hosted on a web page?$?

A. Microsoft Web Sandbox
B. ADsafe
C. Caja
D. dojox.secure
Answer» E.
84.

Consider the following code snippet :var o = new F();o.constructor === FThe output would be :$?

A. false
B. true
C. 0
D. 1
Answer» C. 0
85.

The method that performs the search-and-replace operation to strings for pattern matching is$?

A. searchandreplace()
B. add()
C. edit()
D. replace()
Answer» C. edit()
86.

Why was “The Good Parts” designed as a language subset in JavaScript?$?

A. To improve programmer flexibility
B. To balance the work load of the programmer
C. To create an in-built compiler and interpreter
D. To improve programmer productivity
Answer» E.
87.

When a class B can extend another class A, we say that$?

A. A is the superclass and B is the subclass
B. B is the superclass and A is the subclass
C. Both A and B are the superclass
D. Both A and B are the subclass
Answer» B. B is the superclass and A is the subclass
88.

The properties of the objects act like different kinds of class members. They are$?

A. Public object, Private object, Protected object
B. Constructor object, Function object, Destructor object
C. Constructor object, Prototype object, Instance object
D. Instance method, Static object, Dynamic object
Answer» D. Instance method, Static object, Dynamic object
89.

How can we make methods available on all objects?$?

A. Object.add(methods)
B. Object.methods(add)
C. Object.add.methods(…)
D. Object.prototype
Answer» E.
90.

To define each of the set classes as a property of the sets object (namespace) for the module, the statement is$?

A. sets = sets.AbstractEnumerableSet.extend();
B. sets.SingletonSet = sets.AbstractEnumerableSet.extend(...);
C. sets.SingletonSet = sets.extend(...);
D. sets = sets.extend(...);
Answer» C. sets.SingletonSet = sets.extend(...);
91.

Consider the following code snippetvar sets = com.davidflanagan.collections.sets;What is the programmer trying to do in the above code snippet?$?

A. Importing a single module
B. Importing a module partially
C. Importing a namespace
D. Importing the entire module
Answer» E.
92.

The regular expression to match any one character not between the brackets is$?

A. […]
B. [^]
C. [^…]
D. [D]
Answer» D. [D]
93.

The method that performs the search-and-replace operation to strings for pattern matching is?

A. searchandreplace()
B. add()
C. edit()
D. replace()
Answer» C. edit()
94.

Why was “The Good Parts” designed as a language subset in JavaScript??

A. To improve programmer flexibility
B. To balance the work load of the programmer
C. To create an in-built compiler and interpreter
D. To improve programmer productivity
Answer» E.
95.

The properties of the objects act like different kinds of class members. They are?

A. Public object, Private object, Protected object
B. Constructor object, Function object, Destructor object
C. Constructor object, Prototype object, Instance object
D. Instance method, Static object, Dynamic object
Answer» D. Instance method, Static object, Dynamic object
96.

Consider the following code snippetvar sets = com.davidflanagan.collections.sets;What is the programmer trying to do in the above code snippet??

A. Importing a single module
B. Importing a module partially
C. Importing a namespace
D. Importing the entire module
Answer» E.
97.

The regular expression to match any one character not between the brackets is?

A. […]
B. [^]
C. [^…]
D. [D]
Answer» D. [D]
98.

How can we make methods available on all objects??

A. Object.add(methods)
B. Object.methods(add)
C. Object.add.methods(…)
D. Object.prototype
Answer» E.
99.

To define each of the set classes as a property of the sets object (namespace) for the module, the statement is?

A. sets = sets.AbstractEnumerableSet.extend();
B. sets.SingletonSet = sets.AbstractEnumerableSet.extend(...);
C. sets.SingletonSet = sets.extend(...);
D. sets = sets.extend(...);
Answer» C. sets.SingletonSet = sets.extend(...);
100.

What will be the reaction when a catch clause has no conditionals ?

A. Takes it to be 0
B. Takes it to be 1
C. Takes it to be true
D. Takes it to be false
Answer» D. Takes it to be false