Home
Current Affairs January 2024

What is the correct answer?

4

What will be the output of the following JavaScript code?
var a1 = [,,,];
var a2 = new Array(3);
0 in a1
0 in a2

A. true false

B. false true

C. true true

D. false true

Correct Answer :

A. true false


Explanation: Array a1 is defined with null values. Therefore we can access the indexes 0, 1 and 2. But array a2 is only defined not declared. Therefore we cannot access index 0.

Related Questions

What is the correct answer?

4

The script tag must be placed in __________

A. the head tag

B. the head or body

C. the title or head

D. after the body tag

What is the correct answer?

4

What will be the output of the following JavaScript code?
function info()
{
int a=1;
int b=2;
return a*b;
}
document.write(info());

A. 1

B. 2

C. 3

D. error

What is the correct answer?

4

Consider the following code snippet :
var grand_Total=eval(10*10+5);

The output for the above statement would be :

A. 10*10+5

B. 105 as a string

C. 105 as an integer value

D. Exception is thrown

What is the correct answer?

4

What will be the output of the following JavaScript code?
function equalto()
{
int num=10;
if(num===10)
return true;
else
return false;
}

A. true

B. false

C. runtime error

D. compilation error

What is the correct answer?

4

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

What is the correct answer?

4

If you have a function f and an object o, you can define a method named m of o with

A. o.m=m.f;

B. o.m=f;

C. o=f.m;

D. o=f;

What is the correct answer?

4

What will be the shift() output of the following JavaScript code?
var a = [];
a.unshift(1);
a.unshift(22);
a.shift();
a.unshift(3,[4,5]);
a.shift();
a.shift();
a.shift();

A. 1

B. [4,5]

C. [3,4,5]

D. Exception is thrown

What is the correct answer?

4

A function with no return value is called ___________

A. Procedures

B. Method

C. Static function

D. Dynamic function

What is the correct answer?

4

Consider the following code snippet.
while (a != 0)
{
if (a == 1)
continue;
else
a++;
}

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. The continue keyword breaks out of the loop

What is the correct answer?

4

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. === operator

D. ==opertor

What is the correct answer?

4

What happens in the following javaScript code snippet?
var count = 0;
while (count < 10)
{
console.log(count);
count++;
}

A. The values of count are 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

What is the correct answer?

4

What will be the output of the following Javascript code?
<script>
txt1 = “ one”;
txt1 += “two”;
document.getElementById("demo").innerHTML = txt1;
</script>


A. onetwo

B. one two

C. error

D. undefined

What is the correct answer?

4

Which keyword is used to define the function in javascript?

A. void

B. int

C. function

D. main

What is the correct answer?

4

What will be the output of the following JavaScript code?
const obj1 = { property1: '10'};
const obj2 = Object.freeze(obj1);
obj2.property1 = '20';
console.log(obj2.property1);

A. 10

B. 20

C. Runtime error

D. Compilation error

What is the correct answer?

4

The enumeration order becomes implementation dependent and non-interoperable if ___________

A. If the object inherits enumerable properties

B. The object does not have the properties present in the integer array indices

C. The delete keyword is never used

D. Object.defineProperty() is not used

What is the correct answer?

4

What will be the equivalent output of the following JavaScript code snippet?
x = ~-y;
w = x = y = z;
q = a?b:c?d:e?f:g;

A.

x = ~(-y); w = (x = (y = z));
q = a?b:(c?d:(e?f:g));

B.

x = a?b:(c?d:(e?f:g));
q = ~(-y); w = (x = (y = z));

C.

x = (x = (y = z));w = ~(-y);
q = a?b:(c?d:(e?f:g));

D.

x = ~(-y); w = (x = (y = z));
q = (c?d:(e?f:g));

What is the correct answer?

4

What is the difference between the two lines given below ?
!!(obj1 && obj2);
(obj1 && obj2);

A. Both the lines result in a boolean value True

B. Both the lines result in a boolean value False

C. Both the lines checks just for the existence of the object alone

D. The first line results in a real boolean value whereas the second line merely checks for the existence of the objects

What is the correct answer?

4

A hexadecimal literal begins with __________

A. 00

B. 0x

C. 0X

D. Both 0x and 0X

What is the correct answer?

4

What will be the output of the following Javascript code?
<script>
var x = 5;
var y = 2;
var z = x % y;
document.getElementById("demo").innerHTML = z;
</script>


A. 0

B. 1

C. 2

D. 5

What is the correct answer?

4

JavaScript _________ when there is an indefinite or an infinite value during an arithmetic computation.

A. Prints an exception error

B. Prints an overflow error

C. Displays Infinity

D. Prints the value as such

What is the correct answer?

4

What will be the output of the following Javascript code?
var a= 0;
var b = 0;
while (a < 3)
{
a++;
b += a;
console.log(b);
}

A. 135

B. 123

C. 013

D. 01

What is the correct answer?

4

Consider the following code snippet.
function printArray(a)
{
var len = a.length, i = 0;
if (len == 0)
console.log(Empty Array);
else
{
do
{
console.log(a[i]);
} while (++i < len);
}
}

What does the above 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

What is the correct answer?

4

What will be the output of the following JavaScript code?
const object1 = {
property1: 20
};
console.log(Object.is(object1));

A. 20

B. true

C. false

D. error

What is the correct answer?

4

A conditional expression is also called a _______________

A. Alternative to if-else

B. Immediate if

C. If-then-else statement

D. Switch statement

What is the correct answer?

4

What will happen if reverse() and join() methods are used simultaneously?

A. Reverses and stores in the same array

B. Reverses and concatenates the elements of the array

C. Reverses

D. Stores the elements of an array in normal order

What is the correct answer?

4

JavaScript can be written __________

A. directly into JS file and included into HTML

B. directly on the server page

C. directly into HTML pages

D. directly into the css file

What is the correct answer?

4

Which is a more efficient JavaScript code snippet?
Code 1 :
for(var num=10;num>=1;num--)
{
document.writeln(num);
}

Code 2 :
var num=10;
while(num>=1)
{
document.writeln(num);
num++;
}

A. Code 1

B. Code 2

C. Both Code 1 and Code 2

D. Cannot Compare

What is the correct answer?

4

When an empty statement is encountered, a JavaScript interpreter __________

A. Ignores the statement

B. Prompts to complete the statement

C. Throws an error

D. Shows a warning

What is the correct answer?

4

Do functions in JavaScript necessarily return a value?

A. It is mandatory

B. Not necessary

C. Few functions return values by default

D. some functions do not return any value

What is the correct answer?

4

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

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