JavaScript Language | 10 Minute‐Test 18


Instruction

  • Total number of questions : 10.
  • Time alloted : 10 minutes.
  • Each question carry 1 mark.
  • No Negative marks
  • DO NOT refresh the page.
  • All the best :-).

1.

The method that can be used to create new properties and also to modify the attributes of existing properties is

A.
Object.defineProperty()
B.
Object.defineProperties()
C.
Both a and b
D.
None of the mentioned

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

When used to define new properties, any attributes you omit default to false. Therefore, both Object.defineProperty() and Object.defineProperties() can be used to create and modify the attributes.

2.

You can refresh the webpage in JavaScript by using

A.
window.reload
B.
location.reload
C.
window.refresh
D.
page.refresh

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

One can refresh the webpage in JavaScript by using location.reload.

3.

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

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

One way for a module to avoid the creation of global variables is to use an object as its namespace. Instead of defining global functions and variables, it stores the functions and values as properties of an object (which may be referenced to a global variable).

4.

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

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

The split() method can take regular expressions as its arguments. The split() method generally breaks the string on which it is called into an array of substrings, using the argument as a separator.

5.

Which was one of the first security subsets proposed?

A.
FBJS
B.
Caja
C.
dojox.secure
D.
ADSafe

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

ADsafe was one of the first security subsets proposed. It was created by Douglas Crockford (who also defined The Good Parts subset).ADsafe relies on static verification only, and it uses JSLint as its verifier. It forbids access to most global variables and defines an ADSAFE variable that provides access to a secure API, including special-purpose DOM methods. ADsafe is not in wide use, but it was an influential proof-of-concept that influenced other secure subsets.

6.

Which exception does the Iterators throw from their next() method when there are no more values to iterate, that work on finite collections ?

A.
ExitIteration
B.
AbortIteration
C.
Abort
D.
StopIteration

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

Iterators that work on finite collections throw StopIteration from their next() method when there are no more values to iterate. StopIteration is a property of the global object in JavaScript 1.7. Its value is an ordinary object (with no properties of its own) that is reserved for this special purpose of terminating iterations. Note, in particular,that StopIteration is not a constructor function like TypeError() or RangeError().

7.

What is the code required to delete all “weight” tags?

A.
delete weight(pt).all;
B.
delete pt.element[all];
C.
delete pt;
D.
delete pt..weight;

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

Removing attributes and tags is very easy with the standard delete operator :

delete pt..weight; //delete all <weight> tags

8.

What will be the return value of the write() method when the Node cannot write the data immediately and has to buffer it internally?

A.
0
B.
1
C.
True
D.
False

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

The write() method never blocks. If Node cannot write the data immediately and has to buffer it internally, the write() method returns false.

9.

The JavaScript classes can be instantiated using _____ operator?

A.
create
B.
new
C.
instantiate
D.
create.new

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

Just like the JavaScript classes use new operator to instantiate, so does the Java classes.

10.

Which is the method used for registering handlers?

A.
on()
B.
register()
C.
add()
D.
include()
Submit your test now to view the Results and Statistics with answer explanation.