Home
Current Affairs January 2024

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

Correct Answer :

A. true


Explanation: A === operator is only true if the operands are of the same type and the contents match. Two strings are strictly equal when they have the same sequence of characters, same length, and same characters in corresponding positions.

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

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)

What is the correct answer?

4

A proper scripting language is a __________

A. High level programming language

B. Assembly level programming language

C. Machine level programming language

D. Low level programming language

What is the correct answer?

4

What will be the output of the following JavaScript code?
int sum=0;
var arr = [10,15,20,30];
arr.forEach(function myFunction(element)
{
sum= sum+element;
});
document.writeln(sum);

A. 70

B. 75

C. 10

D. error

What is the correct answer?

4

Consider the following code snippet
function 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 statements execution

C. It is used as a keyword that debugs the entire program at once

D. It is used to find error in the statement

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

The method or operator used to identify the array is __________

A. isarrayType()

B. ==

C. ===

D. typeof

What is the correct answer?

4

What are the three important manipulations done in a for loop on a loop variable?

A. Updation, Incrementation, Initialization

B. Initialization,Testing, Updation

C. Testing, Updation, Testing

D. Initialization,Testing, Incrementation

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?
var person =
{
name: Rahul,
getName: function()
{
nreturn this.name;
}
}
var unboundName = person.getName;
var boundName = unboundName.bind(person);
document.writeln(boundName());

A. runtime error;

B. compilation error

C. Rahul

D. undefined

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

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

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?
int a==2;
int b=4;
int ans=a+b;
print(ans);

A. 2

B. 6

C. 0

D. error

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?
var a = 10;
do {
a += 1;
console.log(a);
} while (a < 5);

A. 11121314

B. 1112

C. 12345

D. 11

What is the correct answer?

4

Consider the following code snippet :
var tensquared = (function(x) {return x*x;}(10));

Will the above code work ?

A. Yes, perfectly

B. Error

C. Exception will be thrown

D. Memory leak

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

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

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)

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

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

One of the special feature of an interpreter in reference with the for loop is that ___________

A. Before each iteration, the interpreter evaluates the variable expression and assigns the name of the property

B. The iterations can be infinite when an interpreter is used

C. The body of the loop is executed only once

D. the iteration is finite when an interpreter is used

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

Which of the following Attribute is used to include External JS code inside your HTML Document?

A. src

B. ext

C. script

D. link

What is the correct answer?

4

Consider the following JavaScript statements.
var text = testing: 1, 2, 3; // Sample text
var pattern = /d+/g // Matches all instances of one or more digits

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

What is the correct answer?

4

A linkage of series of prototype objects is called as ________

A. prototype stack

B. prototype chain

C. prototype class

D. prototypes

What is the correct answer?

4

What will be the output of the following Javascript code?
var a=3.7;
var b=2;
a=ciel(a)
document.writeIn(a*b);

A. 6

B. 7.4

C. 7.5

D. 8

What is the correct answer?

4

What will be the firstname and surname of the following JavaScript code?
var book = {
main title: JavaScript,
'sub-title': The Definitive Guide,
for: all audiences,
author: {
firstname: David,
surname: Flanagan
}
};

A. properties

B. property values

C. property names

D. objects

What is the correct answer?

4

The type of a variable that is volatile is _______________

A. Volatile variable

B. Mutable variable

C. Immutable variable

D. Dynamic variable