Home
Current Affairs January 2024

What is the correct answer?

4

For the below mentioned code snippet:
var o = new Object();

The equivalent statement is:

A. var o = Object();

B. var o;

C. var o= new Object;

D. Object o=new Object();

Correct Answer :

C. var o= new Object;


Explanation: As a special case, for the new operator only, JavaScript simplifies the grammar by allowing the parenthesis to be omitted if there are no arguments in the function call. Hence you can always omit a pair of empty parentheses in a constructor invocation.

Related Questions

What is the correct answer?

4

The method or operator used to identify the array is __________

A. isarrayType()

B. ==

C. ===

D. typeof

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

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

What will be the output of the following JavaScript code?
function code(id,name)
{
this.id = id;
this.name = name;
}
function pcode(id,name)
{
code.call(this,id,name);
}
document.writeln(new pcode(101,vivek).id);

A. vivek

B. 101

C. Runtime error

D. Compilation error

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

Which is an equivalent code to invoke a function m of class o that expects two arguments x and y?

A. o(x,y);

B. o.m(x) && o.m(y);

C. m(x,y);

D. o.m(x,y);

What is the correct answer?

4

What will be the output of the following JavaScript code?
var grade='B';
var result;
switch(grade)
{
case 'A':
{
result+=10;
break;
}
case 'B':
{
result+= 9;
break;
}
case 'C':
{
result+= 8;
break;
}
default:
result+= 0;
}
document.write(result);

A. 10

B. 9

C. 8

D. 0

What is the correct answer?

4

What will be the output of the following Javascript code?
<script>
document.getElementById("demo").innerHTML = typeof "John"
</script>


A. integer

B. number

C. string

D. error

What is the correct answer?

4

What will be the output of the following JavaScript code?
Int a=1;
if(a>10)
{
document.write(10);
}
else
{
document.write(a);
}

A. 10

B. 0

C. 1

D. Undefined

What is the correct answer?

4

Among the keywords below, which one is not a statement?

A. debugger

B. with

C. if

D. use strict

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

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

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

What will be the output of the following JavaScript code?

A. 125

B. 25

C. 5

D. Error

What is the correct answer?

4

Consider the following code snippet :
var c = counter(), d = counter();
c.count()
d.count()
c.reset()
c.count()
d.count()

The state stored in d is :

A. 1

B. 0

C. Null

D. Undefined

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

What will be the output of the following JavaScript code?
var grade='E';
var result;
switch(grade)
{
case 'A':
result+=10;
case 'B':
result+= 9;
case 'C':
result+= 8;
default:
result+= 0;
}
document.write(result);

A. 10

B. 0

C. 18

D. 17

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

What will be the output of the following JavaScript code?

A. 1.01

B. 1.047

C. 1.00

D. 1.4

What is the correct answer?

4

What will be the output of the following JavaScript code?
const object1 = {};
a = Symbol('a');
b = Symbol.for('b');
object1[a] = 'harry';
object1[b] = 'derry';
const objectSymbols = Object.getOwnPropertySymbols(object1);
console.log(objectSymbols.length);

A. 0

B. 2

C. 1

D. Error

What is the correct answer?

4

What will be the output of the following JavaScript code?

A. 7.25

B. -7.25

C. 7

D. -7

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

Consider the following code snippet :
var string2Num=parseInt(123xyz);

The result for the above code snippet would be :

A. 123

B. 123xyz

C. Exception

D. NaN

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

The generalised syntax for a real number representation is __________

A. [digits][.digits][(E|e)[(+|-)]digits]

B. [digits][+digits][(E|e)[(+|-)]digits]

C. [digits][(E|e)[(+|-)]digits]

D. [.digits][digits][(E|e)[(+|-)]digits]

What is the correct answer?

4

What will be the output of the following JavaScript code?
int a=4;
int b=1;
int c=0;
If(a==b)
document.write(a);
else if(a==c)
document.write(a);
else
document.write(c);

A. 4

B. 1

C. Error

D. 0

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 will be the step of the interpreter in a jump statement when an exception is thrown?

A. The interpreter stops its work

B. The interpreter throws another exception

C. The interpreter jumps to the nearest enclosing exception handler

D. The interpreter throws an error

What is the correct answer?

4

JavaScript is ideal to ________

A. make computations in HTML simpler

B. minimize storage requirements on the web server

C. increase the download time for the client

D. increase the loading time of the website

What is the correct answer?

4

What will be the output of the following JavaScript code?
function output(object)
{
var place=object ? object.place : Italy;
return clean:+ place;
}
console.log(output({place:India}));

A. clean:India

B. clean:Italy

C. error

D. undefined