Question 1
EasyWhat is the output of this program?
console.log(typeof );
Popular companies
Prepare company by company
Hiring pattern, syllabus, past questions and mocks for each company.
All companiesPractice by subject
Programming Languages
What is the output of this program?
console.log(typeof );
undefined
number
string
object
Answer: C
typeof returns 'string' for text values.
What is the output of this program?
console.log(typeof NaN);
number
NaN
undefined
object
Answer: A
NaN ('not a number') is still of type 'number' in JavaScript.
What is the output of this program?
console.log('5' == 5);
true
undefined
false
Error
Answer: A
== converts types before comparing, so '5' == 5 is true.
What is the output of this program?
console.log('5' === 5);
undefined
true
Error
false
Answer: D
=== compares without type conversion: a string is never strictly equal to a number.
Which keyword declares a variable whose binding can't be reassigned?
const
let
static
var
Answer: A
const prevents reassignment (an object it holds can still be changed). let and var allow reassignment.
What is the output of this program?
console.log(JSON.stringify([1, 2, 3].map(x => x * 2)));
[2,4,6]
[1,4,9]
Answer: A
map applies the function to each element, doubling them; JSON.stringify prints the resulting array.
What is the output of this program?
console.log([10, 20, 30].length);
2
Error
Answer: D
length gives the number of elements in an array.
What is the output of this program?
console.log(typeof 42);
number
integer
int
float
Answer: A
JavaScript has one numeric type for both integers and decimals, reported as "number".
What is the output of this program?
console.log("5" + 3);
8
53
5 3
Error
Answer: B
If either operand of + is a string, the other is converted and the two are joined.
What is the output of this program?
console.log("5" - 3);
NaN
Error
2
53
Answer: C
6
[1,2,3]
undefined
3