Explore topic-wise MCQs in Javascript.

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

1.

Consider the following snippet code:var string1 = "123";var intvalue = 123;alert( string1 + intvalue );The result would be

A. 123246
B. 246
C. 123123
D. Exception
Answer» D. Exception
2.

Consider the following code snippet. What will be the role of the continue keyword in the above code snippet?

A. The continue keyword restarts the loop
B. The continue keyword skips the next iteration
C. The continue keyword skips the rest of the statements in that iteration
D. None of the mentioned
Answer» D. None of the mentioned
3.

Consider the following code snippet. In the snippet, firstname and surname are

A. properties
B. property values
C. property names
D. objects
Answer» D. objects
4.

Identify the process done in the below code snippet

A. Object Encapsulation
B. Object Serialization
C. Object Abstraction
D. Object Encoding
Answer» C. Object Abstraction
5.

Variable declared inside JavaScript Function will be called as ____________.

A. Local Variables
B. Global Variables
C. Both a and b
D. None of the above
Answer» B. Global Variables
6.

It is good to include JS code inside footer section in order to speed up the Page loading time of Webpage.

A. True
B. False
C. Can't say
D. None of the above
Answer» B. False
7.

Consider the following code snippetfunction f(o) { if (o === undefined) debugger;}What could be the task of the statement debugger?

A. It does nothing but a simple breakpoint
B. It debugs the error in that statement and restarts the statement's execution
C. It is used as a keyword that debugs the entire program at once
D. All of the mentioned
Answer» B. It debugs the error in that statement and restarts the statement's execution
8.

The output for the following code snippet would most appropriately be

A. 10
B. Error
C. 1
D. 5
Answer» D. 5
9.

Which attribute is used to specifies that the script is executed when the page has finished parsing (only for external scripts)

A. parse
B. async
C. defer
D. type
Answer» D. type
10.

To determine whether one object is the prototype of (or is part of the prototype chain of) another object, one should use the

A. isPrototypeOf() method
B. equals() method
C.
Answer» B. equals() method
11.

Consider the following statements:var text = "testing: 1, 2, 3"; // Sample textvar pattern = /d+/g // Matches all instances of one or more digitsIn order to check if the pattern matches with the string "text", the statement is

A. text==pattern
B. text.equals(pattern)
C. text.test(pattern)
D. pattern.test(text)
Answer» E.
12.

JS code included inside head section is loaded before loading page.

A. True
B. False
C. Can't say
D. None of the above
Answer» B. False
13.

The "var" and "function" are

A. Keywords
B. Declaration statements
C. Datatypes
D. Prototypes
Answer» C. Datatypes
14.

Consider the following code snippet. What does the code result?

A. Prints the numbers in the array in order
B. Prints the numbers in the array in the reverse order
C. Prints 0 to the length of the array
D. Prints "Empty Array"
Answer» B. Prints the numbers in the array in the reverse order
15.

Which is a more efficient code snippet ?

A. Code 1
B. Code 2
C. Both Code 1 and Code 2
D. Cannot Compare
Answer» B. Code 2
16.

Consider the following statement:var count = 0;while (count < 10) { console.log(count); count++;}In the above code snippet, what happens?

A. The values of count is logged or stored in a particular location or storage
B. The value of count from 0 to 9 is displayed in the console
C. An error is displayed
D. An exception is thrown
Answer» C. An error is displayed
17.

"An expression that can legally appear on the left side of an assignment expression." is a well known explanation for variables, properties of objects, and elements of arrays. They are called

A. Properties
B. Prototypes
C. Lvalue
D. Definition
Answer» D. Definition
18.

The snippet that has to be used to check if "a" is not equal to "null" is

A. if(a!=null)
B. if (!a)
C. if(a!null)
D. if(a!==null)
Answer» E.
19.

Underscore can be used as first letter while declaring variable in JavaScript.

A. True
B. False
C. Depends on the browser
D. None of the above
Answer» B. False
20.

The JavaScript's syntax calling ( or executing ) a function or method is called

A. Primary expression
B. Functional expression
C. Invocation expression
D. Property Access Expression
Answer» D. Property Access Expression
21.

We can embed JS code inside HTML directly ?

A. True
B. False
C. Depends on the browser
D. None of the above
Answer» B. False
22.

The escape sequence "f" stands for

A. Floating numbers
B. Representation of functions that returns a value
C. f is not present in JavaScript
D. Form feed
Answer» E.
23.

Local Variables are destroyed after execution of function.

A. True
B. False
C. Can't say
D. None of the above
Answer» B. False
24.

A hexadecimal literal begins with

A. 00
B. 0x
C. 0X
D. Both 0x and 0X
Answer» E.
25.

When there is an indefinite or an infinity value during an arithmetic value computation, javascript

A. Prints an exception error
B. Prints an overflow error
C. Displays "Infinity"
D. Prints the value as such
Answer» D. Prints the value as such
26.

What kind of an expression is "new Point(2,3)"?

A. Primary Expression
B. Object Creation Expression
C. Invocation Expression
D. Constructor Calling Expression
Answer» C. Invocation Expression
27.

A linkage of series of prototype objects is called as :

A. prototype stack
B. prototype chain
C. prototype class
D. prototypes
Answer» C. prototype class
28.

Assume that we have to convert "false" that is a non-string to string. The command that we use is (without invoking the "new" operator)

A. false.toString()
B. String(false)
C. String newvariable="false"
D. Both false.toString() and String(false)
Answer» E.
29.

Consider the below given syntax:book[datatype]=assignment_value;In the above syntax, the datatype within the square brackets must be

A. An integer
B. A String
C. An object
D. None of the mentioned
Answer» C. An object
30.

Consider the following code snippetfunction tail(o) { for (; o.next; o = o.next) ; return o;}Will the above code snippet work? If not, what will be the error?

A. No, this will throw an exception as only numerics can be used in a for loop
B. No, this will not iterate
C. Yes, this will work
D. No, this will result in a runtime error with the message "Cannot use Linked List"
Answer» D. No, this will result in a runtime error with the message "Cannot use Linked List"
31.

The main purpose of a "Live Wire" in NetScape is to

A. Create linkage between client side and server side
B. Permit server side, JavaScript code, to connect to RDBMS
C. Support only non relational database
D. To interpret JavaScript code
Answer» C. Support only non relational database