Home
Current Affairs January 2024

What is the correct answer?

4

What will be the output of the following JavaScript code?
function height()
{
var height = 123.56;
var type = (height>=190) ? tall : short;
return type;
}

A. 123.56

B. 190

C. tall

D. short

Correct Answer :

D. short


Explanation: The ternery operator is used as a comparison operator which works on three operands. The statement in the above code initializes type variable with the value short which is returned through the function.

Related Questions

What is the correct answer?

4

The unordered collection of properties, each of which has a name and a value is called _________

A. String

B. Object

C. Serialized Object

D. Array

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

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

What will be the output of the following JavaScript code?
var obj=
{
length:20,
height:35,
}
if (breadth' in obj === false)
{
obj.breadth = 12;
}
console.log(obj.breadth);

A. 20

B. 12

C. undefined

D. error

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

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();

What is the correct answer?

4

JavaScript Code can be called by using ____________

A. RMI

B. Triggering Event

C. Preprocessor

D. Function/Method

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

Which attribute is used to specify that the script is executed when the page has finished parsing? (only for external scripts)

A. parse

B. a sync

C. defer

D. type

What is the correct answer?

4

What will be the output of the following JavaScript code?
var values=[one,two,Three];
var ans=values.shift();
document.writeln(ans);

A. one

B. two

C. three

D. error

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

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 observation made in the following JavaScript code?
var count = [1,,3];

A. The omitted value takes undefined

B. This results in an error

C. This results in an exception

D. The omitted value takes an integer value

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(option)
{
return (option ? yes : no);
}
bool ans=true;
console.log(output(ans));

A. Yes

B. No

C. Runtime error

D. Compilation 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

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

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

The primary purpose of the array map() function is that it __________

A. maps the elements of another array into itself

B. passes each element of the array and returns the necessary mapped elements

C. passes each element of the array on which it is invoked to the function you specify, and returns an array containing the values returned by that function

D. pass the elements of the array into another array

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

The reduce and reduceRight methods follow a common operation called __________

A. filter and fold

B. inject and fold

C. finger and fold

D. fold

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 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 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 happen if the body of a for/in loop deletes a property that has not yet been enumerated?

A. The property will be stored in a cache

B. The loop will not run

C. That property will not be enumerated

D. The property will be enumerated

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

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

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

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