Home
Current Affairs January 2024

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

Correct Answer :

C. 105 as an integer value


Explanation: eval() is a function property of the global object. The argument of the eval() function is a string. If the string represents an expression, eval() evaluates the expression. If the argument represents one or more JavaScript statements, eval() evaluates the statements.

Related Questions

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

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

When does the function name become optional in JavaScript?

A. When the function is defined as a looping statement

B. When the function is defined as expressions

C. When the function is predefined

D. when the function is called

What is the correct answer?

4

Which of the operator is used to test if a particular property exists or not?

A. in

B. exist

C. within

D. exists

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 is the purpose of a return statement in a function?

A. Returns the value and continues executing rest of the statements, if any

B. Returns the value and stops the program

C. Returns the value and stops executing the function

D. Stops executing the function and returns the value

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

The var and function are __________

A. Keywords

B. Declaration statements

C. Data types

D. Prototypes

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

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?
const object1 = {
property1: 20
};
console.log(Object.is(object1));

A. 20

B. true

C. false

D. error

What is the correct answer?

4

What will be the output of the following Javascript code?
int a=0;
for(a;a<5;a++);
console.log(a);

A. 0

B. error

C. 4

D. 5

What is the correct answer?

4

JavaScript is a _______________ language.

A. Object-Oriented

B. High-level

C. Assembly-language

D. Object-Based

What is the correct answer?

4

In the following switch syntax, the expression is compared with the case labels using which of the following operator(s)?
switch(expression)
{
statements
}

A. ==

B. equals

C. equal

D. ===

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

What will be the output of the following JavaScript code?
var a=5 , b=1
var obj = { a : 10 }
with(obj)
{
alert(b)
}

A. 10

B. Error

C. 1

D. 5

What is the correct answer?

4

A JavaScript program developed on a Unix Machine ________

A. will throw errors and exceptions

B. must be restricted to a Unix Machine only

C. will work perfectly well on a Windows Machine

D. will be displayed as a JavaScript text on the browser

What is the correct answer?

4

Consider the following code snippet.
for(var p in o)
console.log(o[p]);

The above code is equivalent to which code?

A.

for (var i = 0;i < a.length;i++)
console.log(a[i]);

B.

for (int i = 0;i < a.length;i++)
console.log(a[i]);

C.

for (var i = 0;i <= a.length;i++)
console.log(a[i]);

D.

for (var i = 1;i < a.length;i++)
console.log(a[i]);

What is the correct answer?

4

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


A. 5

B. 10

C. 50

D. Error

What is the correct answer?

4

What will be the output of the following JavaScript code?
var val1=[1,2,3];
var val2=[6,7,8];
var result=val1.concat(val2);
document.writeln(result);

A. 1, 2, 3

B. Error

C. 1, 2, 3, 6, 7, 8

D. 123

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 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

The function stops its execution when it encounters?

A. continue statement

B. break statement

C. goto statement

D. return statement

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 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

What will happen if a return statement does not have an associated expression?

A. It returns the value 0

B. It will throw an exception

C. It returns the undefined value

D. It will throw an error

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

The property of a primary expression is ____________

A. stand-alone expressions

B. basic expressions containing all necessary functions

C. contains variable references alone

D. contains only keywords

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 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