JavaScript Variables & Datatypes MCQs

1 min read

JavaScript uses variables as named containers to store data values, declared using keywords such as var, let, and const. The language features seven primitive data types String, Number, BigInt, Boolean, Undefined, Null, and Symbol alongside non-primitive reference types like Object, Array, and Function. Variable scoping changed significantly in ES6, which introduced block-scoped let and const to complement function-scoped var and address issues like unexpected hoisting. Understanding type coercion, the typeof operator, and memory storage distinctions (stack vs. heap) is critical for writing predictable code. Mastering these fundamental concepts is essential for success in JavaScript technical interviews and frontend developer certifications.

1. Which primitive data type was introduced in ECMAScript 2020 (ES11) to represent arbitrarily large integers?

a) Number
b) BigInt
c) LongInt
d) LargeNumber
Correct Answer: b) BigInt
Explanation:
BigInt is a primitive wrapper added in ES2020 that allows safe storage and operations on large integers beyond Number.MAX_SAFE_INTEGER.

2. What is the result of evaluating `typeof NaN` in JavaScript?

a) undefined
b) NaN
c) number
d) object
Correct Answer: c) number
Explanation:
Despite standing for 'Not-a-Number', NaN is specified in IEEE 754 floating-point standard as a special numeric value, making its typeof 'number'.

3. Which keyword allows re-declaration of the same variable name within the same scope?

a) let
b) const
c) var
d) static
Correct Answer: c) var
Explanation:
Variables declared with 'var' can be re-declared within the same functional or global scope without raising a SyntaxError.

4. What happens when you declare a variable with `const` without initializing it?

a) It defaults to undefined
b) It defaults to null
c) It throws a SyntaxError
d) It throws a ReferenceError
Correct Answer: c) SyntaxError
Explanation:
Const declarations must be initialized during declaration; failing to provide an initial value throws a SyntaxError.

5. Which of the following values is primitive?

a) Symbol("id")
b) new Number(42)
c) ["a", "b"]
d) { key: "value" }
Correct Answer: a) Symbol("id")
Explanation:
Symbols are immutable primitive values. Objects constructed via 'new Number()' are object wrappers, not primitives.

6. What is the Temporal Dead Zone (TDZ)?

a) The execution phase where garbage collection destroys unused variables
b) The period between entering scope and variable declaration for let/const where accessing it throws a ReferenceError
c) The time delay between asynchronous task creation and execution
d) The global scope area where var declarations overwrite existing properties
Correct Answer: b) The period between entering scope and variable declaration for let/const where accessing it throws a ReferenceError
Explanation:
TDZ occurs from the start of the block scope until the point where the let/const variable declaration is executed.

7. What is the output of `console.log(typeof null)`?

a) null
b) undefined
c) object
d) symbol
Correct Answer: c) object
Explanation:
This is a historical bug from the first version of JavaScript where type tags assigned 000 to object references, and null was represented as a null pointer (0x00).

8. What is the value of `a` after running `let a; console.log(a);`?

a) null
b) undefined
c) 0
d) ReferenceError
Correct Answer: b) undefined
Explanation:
Variables declared with let or var without an initial explicit assignment are automatically assigned the default value undefined.

9. Which variable scope is created inside an `if` statement when using `let`?

a) Global scope
b) Function scope
c) Block scope
d) Module scope
Correct Answer: c) Block scope
Explanation:
The 'let' and 'const' keywords bind variable declarations to the immediate enclosing block context delimited by curly braces {}.

10. What is the output of `console.log(1 / 0)`?

a) Infinity
b) NaN
c) 0
d) ZeroDivisionError
Correct Answer: a) Infinity
Explanation:
In JS IEEE 754 arithmetic operations, dividing a positive number by zero results in global constant numeric value Infinity.

11. What does `Number.MAX_SAFE_INTEGER` represent?

a) 2^31 - 1
b) 2^53 - 1
c) 2^64 - 1
d) 10^308
Correct Answer: b) 2^53 - 1
Explanation:
Number.MAX_SAFE_INTEGER (9007199254740991) represents the maximum integer that can be safely and precisely represented in double-precision float.

12. What will `console.log(typeof typeof 1)` output?

a) number
b) string
c) undefined
d) object
Correct Answer: b) string
Explanation:
typeof 1 evaluates to string "number". Evaluating typeof "number" yields string "string".

13. Which statement correctly describes how primitive values are stored in memory compared to reference values?

a) Primitives are stored directly on the execution stack/variable location; reference values store pointers to heap memory addresses
b) Primitives are stored in heap memory; reference values are stored directly on stack
c) Both primitives and reference values are stored exclusively on the heap
d) Primitives are mutable; reference values are strictly immutable
Correct Answer: a) Primitives are stored directly on the execution stack/variable location; reference values store pointers to heap memory addresses
Explanation:
Primitive data types are stored directly in location where variable is bound, while objects reside on heap with memory address references saved in variable slots.

14. What will `console.log(typeof Symbol("foo"))` return?

a) object
b) symbol
c) string
d) function
Correct Answer: b) symbol
Explanation:
Symbols have their own dedicated primitive data type identifier in JavaScript called 'symbol'.

15. What is the output of `console.log(0.1 + 0.2 === 0.3)`?

a) true
b) false
c) undefined
d) TypeError
Correct Answer: b) false
Explanation:
Due to binary double-precision floating-point arithmetic (IEEE 754), 0.1 + 0.2 evaluates to 0.30000000000000004, which is not strictly equal to 0.3.

16. Which of the following statement declarations attaches the created variable as a property on the global `window` object in browsers?

a) var x = 10;
b) let x = 10;
c) const x = 10;
d) all of the above
Correct Answer: a) var x = 10;
Explanation:
Global declarations using 'var' create properties on the global object (window in browser), whereas global 'let' and 'const' declarations do not.

17. What happens when mutating an array assigned to a `const` variable?

a) Throws a TypeError
b) Throws a ReferenceError
c) Mutates successfully without error
d) Fails silently in non-strict mode
Correct Answer: c) Mutates successfully without error
Explanation:
The 'const' modifier prevents reassigning the variable identifier reference, but contents of referenced mutable structures like arrays/objects can be altered.

18. What is the output of `console.log(String(null))`?

a) "null"
b) "undefined"
c) ""
d) TypeError
Correct Answer: a) "null"
Explanation:
Explicit string conversion using String() converts the primitive value null directly to string representation "null".

19. What is the output of `console.log(Number(true))`?

a) 0
b) 1
c) NaN
d) true
Correct Answer: b) 1
Explanation:
Converting boolean primitive value true to a numeric type coerces it explicitly to integer 1.

20. What is the output of `console.log(Number(undefined))`?

a) 0
b) null
c) NaN
d) undefined
Correct Answer: c) NaN
Explanation:
Numeric conversion of value undefined cannot resolve to a valid real number, producing value NaN.

21. What is the output of `console.log(Number(null))`?

a) 0
b) NaN
c) 1
d) null
Correct Answer: a) 0
Explanation:
In JavaScript type coercion rules, explicit numerical conversion of null evaluates directly to 0.

22. What will `console.log(Boolean([]))` return?

a) false
b) true
c) undefined
d) TypeError
Correct Answer: b) true
Explanation:
All objects and arrays in JS (even completely empty ones) are truthy values, evaluating to true when coerced to boolean.

23. What will `console.log(Boolean("false"))` return?

a) false
b) true
c) NaN
d) SyntaxError
Correct Answer: b) true
Explanation:
Any non-empty string in JS is truthy when converted to boolean, regardless of textual content.

24. Which operator returns the primitive data type string identifier of an uninitialized or evaluated operand?

a) instanceof
b) typeof
c) type
d) isType
Correct Answer: b) typeof
Explanation:
The 'typeof' unary operator evaluates an expression operand and returns a string indicating its uncoerced primitive type.

25. What is the output of `console.log("5" - - "3")`?

a) 2
b) 8
c) "5-3"
d) NaN
Correct Answer: b) 8
Explanation:
Unary minus converts "3" to -3. Subtraction operator forces string "5" to number 5. Calculation evaluates: 5 - (-3) = 8.

26. What is the output of `console.log("10" * "2")`?

a) "20"
b) 20
c) "102"
d) NaN
Correct Answer: b) 20
Explanation:
Multiplication operator (*) performs numeric coercion on both string operands, converting them into 10 and 2 to produce number 20.

27. What will `console.log(typeof [])` evaluate to?

a) array
b) object
c) list
d) undefined
Correct Answer: b) object
Explanation:
Arrays are sub-types of objects in JavaScript; typeof operator returns "object" for array references.

28. Which method should be used to reliably verify whether a variable holds an Array instance?

a) typeof arr === 'array'
b) Array.isArray(arr)
c) arr.type() === 'array'
d) arr.isSequence()
Correct Answer: b) Array.isArray(arr)
Explanation:
Array.isArray() is the standard built-in static method designed specifically to determine whether a given target is an array.

29. Which of the following variable names is illegal in JavaScript?

a) $amount
b) _user_name
c) 2ndUser
d) user2
Correct Answer: c) 2ndUser
Explanation:
JavaScript variable identifiers cannot begin with a digit character (0-9).

30. What is the result of assigning a value to an undeclared variable in strict mode (`"use strict";`)?

a) Creates a global variable automatically
b) Throws a ReferenceError
c) Throws a SyntaxError
d) Assigns value to null
Correct Answer: b) ReferenceError
Explanation:
In strict mode, assigning a value to an undeclared variable identifier prevents accidental global leak and throws a ReferenceError.

31. Which operator performs safe equality comparison without type coercion?

a) ==
b) =
c) ===
d) !=
Correct Answer: c) ===
Explanation:
Strict equality operator (===) checks both numeric/primitive value equality and data type without performing implicit coercion.

32. What is the output of `console.log(null == undefined)`?

a) true
b) false
c) null
d) TypeError
Correct Answer: a) true
Explanation:
Under loose equality rules (==), null and undefined are specified as loosely equal to each other and to nothing else.

33. What is the output of `console.log(null === undefined)`?

a) true
b) false
c) undefined
d) TypeError
Correct Answer: b) false
Explanation:
Under strict equality (===), null and undefined retain distinct data types ('object' vs 'undefined'), evaluating to false.

34. What will `console.log(typeof function(){})` return?

a) object
b) function
c) method
d) closure
Correct Answer: b) function
Explanation:
Even though functions are object subtypes internally, the spec dictates that typeof callable objects returns string "function".

35. What is the default value of properties in an object that have not been assigned?

a) null
b) undefined
c) false
d) 0
Correct Answer: b) undefined
Explanation:
Accessing non-existent properties on objects returns primitive value undefined.

36. What will `console.log(typeof 10n)` return?

a) number
b) bigint
c) long
d) integer
Correct Answer: b) bigint
Explanation:
The 'n' suffix denotes a BigInt primitive literal; passing it to typeof returns string "bigint".

37. What will `console.log(10n == 10)` evaluate to?

a) true
b) false
c) TypeError
d) NaN
Correct Answer: a) true
Explanation:
Loose equality (==) coerces numeric representations across Number and BigInt types, confirming their numeric equality.

38. What will `console.log(10n === 10)` evaluate to?

a) true
b) false
c) TypeError
d) NaN
Correct Answer: b) false
Explanation:
Strict equality (===) fails because BigInt (10n) and Number (10) are different data types.

39. What occurs when attempting `10n + 5` without explicit type conversion?

a) Returns 15n
b) Returns 15
c) Throws a TypeError
d) Returns "10n5"
Correct Answer: c) TypeError
Explanation:
JavaScript prohibits mixing BigInt and standard Number types in arithmetic operations to prevent precision loss; it throws a TypeError.

40. Which primitive value represents intentional absence of any object value?

a) undefined
b) void
c) null
d) NaN
Correct Answer: c) null
Explanation:
The value null is a primitive representing intentional absence of object value or reference.

41. What will `console.log("Foo" + + "Bar")` output?

a) FooBar
b) FooNaN
c) FooUndefined
d) TypeError
Correct Answer: b) FooNaN
Explanation:
Unary plus operator on string "Bar" evaluates to NaN. Concatenating string "Foo" with NaN yields string "FooNaN".

42. What is the result of `console.log([] == ![])`?

a) true
b) false
c) TypeError
d) NaN
Correct Answer: a) true
Explanation:
![] converts truthy array to false. Expression becomes [] == false. Both sides coerce to number 0 (0 == 0), evaluating to true.

43. What is the output of `console.log(true + true + false)`?

a) 2
b) true
c) 1
d) NaN
Correct Answer: a) 2
Explanation:
Addition forces numeric coercion of booleans: true becomes 1, false becomes 0. Evaluating: 1 + 1 + 0 = 2.

44. What happens when using variable defined with `var` before its actual declaration in script code?

a) Throws a ReferenceError
b) Throws a SyntaxError
c) Returns undefined due to hoisting
d) Returns null
Correct Answer: c) Returns undefined due to hoisting
Explanation:
'var' declarations are hoisted to top of scope and initialized with undefined immediately during creation phase.

45. Which statement about `const` objects is true?

a) Object properties cannot be updated or added
b) The object identifier reference cannot be reassigned to a new memory address
c) The object is automatically frozen with Object.freeze()
d) Properties can only be updated inside strict mode
Correct Answer: b) The object identifier reference cannot be reassigned to a new memory address
Explanation:
Const creates an immutable binding reference to target value, but does not render underlying object content immutable.

46. What will `console.log(typeof Symbol())` output?

a) symbol
b) object
c) string
d) undefined
Correct Answer: a) symbol
Explanation:
Primitive wrapper Symbol constructor returns primitive data type 'symbol'.

47. What is the output of `console.log(typeof (function(){}()))`?

a) function
b) undefined
c) object
d) null
Correct Answer: b) undefined
Explanation:
The immediately invoked function expression returns nothing (undefined); typeof undefined evaluates to string "undefined".

48. Which primitive value is unique and guaranteed never to clash with any other key when used as an object property?

a) BigInt
b) Symbol
c) String
d) Null
Correct Answer: b) Symbol
Explanation:
Symbols are guaranteed unique primitive tokens specifically designed for non-colliding object property keys.

49. What is the output of `console.log(Symbol("key") === Symbol("key"))`?

a) true
b) false
c) TypeError
d) undefined
Correct Answer: b) false
Explanation:
Every call to Symbol() produces a totally unique primitive value, even if supplied identical label descriptions.

50. What is the output of `console.log(typeof NaN)` vs `console.log(isNaN("abc"))`?

a) "number" and true
b) "NaN" and true
c) "number" and false
d) "undefined" and true
Correct Answer: a) "number" and true
Explanation:
typeof NaN is string "number". Global function isNaN("abc") converts "abc" to NaN first, returning true.

51. What is the key difference between global `isNaN()` and `Number.isNaN()`?

a) Global isNaN converts operand to number first; Number.isNaN checks if value is currently NaN without conversion
b) Number.isNaN converts operand to string first
c) Global isNaN checks strict equality; Number.isNaN checks loose equality
d) There is no functional difference
Correct Answer: a) Global isNaN converts operand to number first; Number.isNaN checks if value is currently NaN without conversion
Explanation:
Number.isNaN() does not perform implicit type coercion; it returns true only if argument is of type Number and equals NaN.

52. What is the output of `console.log(Number.isNaN("abc"))`?

a) true
b) false
c) TypeError
d) NaN
Correct Answer: b) false
Explanation:
Because "abc" is a string data type and Number.isNaN doesn't coerce types, it immediately returns false.

53. What is the output of `console.log(isNaN("abc"))`?

a) true
b) false
c) TypeError
d) NaN
Correct Answer: a) true
Explanation:
Global isNaN coercively casts non-numeric string "abc" to NaN, resulting in true.

54. What is the output of `console.log("5" == 5)`?

a) true
b) false
c) TypeError
d) undefined
Correct Answer: a) true
Explanation:
The loose equality operator (==) coerces string "5" into number 5 prior to comparison.

55. What is the output of `console.log("5" === 5)`?

a) true
b) false
c) TypeError
d) undefined
Correct Answer: b) false
Explanation:
Strict comparison (===) checks data types without conversion; string and number types do not match.

56. Which of the following creates a wrapper object rather than a primitive number value?

a) let x = Number(5);
b) let x = 5;
c) let x = new Number(5);
d) let x = parseInt("5");
Correct Answer: c) let x = new Number(5);
Explanation:
Using 'new' with constructor wrapper functions creates an Object instance holding primitive value internally.

57. What will `console.log(typeof new Number(5))` return?

a) number
b) object
c) primitive
d) undefined
Correct Answer: b) object
Explanation:
Using constructor function with operator 'new' returns object instance, yielding "object" from typeof.

58. What will `console.log(typeof Number(5))` return?

a) number
b) object
c) function
d) undefined
Correct Answer: a) number
Explanation:
Calling Number() directly as a function without 'new' performs explicit primitive conversion, returning primitive number.

59. Which JavaScript built-in data structure stores unique values of any data type?

a) Map
b) Set
c) WeakMap
d) Object
Correct Answer: b) Set
Explanation:
Set is an ES6 reference data type collection structure designed specifically to store unique primitive or reference values.

60. What is the output of `console.log(typeof null === 'object')`?

a) true
b) false
c) null
d) undefined
Correct Answer: a) true
Explanation:
typeof null returns string "object", making strict string equality check evaluate to true.

61. Which primitive type has exactly one value created for unique identification?

a) Undefined
b) Null
c) Symbol
d) Boolean
Correct Answer: c) Symbol
Explanation:
Symbols generate primitive values guaranteed to be completely unique across an entire application runtime.

62. What is the output of `console.log(0 == "")`?

a) true
b) false
c) TypeError
d) undefined
Correct Answer: a) true
Explanation:
Under loose equality rules, both empty string "" and boolean values coerce to numeric 0.

63. What is the output of `console.log(0 === "")`?

a) true
b) false
c) TypeError
d) undefined
Correct Answer: b) false
Explanation:
Strict equality comparison fails because operand data types (Number vs String) are not identical.

64. What is the output of `console.log(false == "0")`?

a) true
b) false
c) TypeError
d) undefined
Correct Answer: a) true
Explanation:
During loose equality, false coerces to number 0, and string "0" coerces to number 0, making 0 == 0 true.

65. What is the output of `console.log(false === "0")`?

a) true
b) false
c) TypeError
d) undefined
Correct Answer: b) false
Explanation:
Strict equality comparison prevents coercion between Boolean and String types.

66. What is the result of evaluating `console.log(typeof true)`?

a) boolean
b) Boolean
c) logical
d) bit
Correct Answer: a) boolean
Explanation:
typeof returns lowercase primitive type names; primitive booleans output "boolean".

67. What will `console.log(1 + 2 + "3")` output?

a) "123"
b) "33"
c) 6
d) NaN
Correct Answer: b) "33"
Explanation:
Operators evaluate left-to-right: 1 + 2 equals numeric 3. Then numeric 3 + string "3" performs string concatenation to produce "33".

68. What will `console.log("1" + 2 + 3)` output?

a) "15"
b) "123"
c) 6
d) NaN
Correct Answer: b) "123"
Explanation:
Left-to-right: "1" + 2 yields string "12". Next, string "12" + 3 concatenates to string "123".

69. What is the result of `console.log(typeof Infinity)`?

a) number
b) infinity
c) undefined
d) object
Correct Answer: a) number
Explanation:
Infinity is a numeric property of the global object representing numerical infinity.

70. Which of the following options represents a falsy value in JavaScript?

a) "0"
b) []
c) {}
d) 0n
Correct Answer: d) 0n
Explanation:
BigInt 0n is a falsy value in JavaScript. Strings like "0", empty arrays [], and empty objects {} are truthy.

71. How many primitive data types exist in modern ECMAScript specifications?

a) 5
b) 6
c) 7
d) 8
Correct Answer: c) 7
Explanation:
JavaScript contains exactly 7 primitive types: Undefined, Null, Boolean, Number, BigInt, String, and Symbol.

72. Which of the following is NOT a primitive data type in JavaScript?

a) Boolean
b) Symbol
c) Object
d) Undefined
Correct Answer: c) Object
Explanation:
Object (including arrays, functions, and maps) is a structural reference data type, not a primitive data type.

73. What is the output of `console.log(typeof undeclaredVar)` when `undeclaredVar` was never declared?

a) ReferenceError
b) undefined
c) null
d) object
Correct Answer: b) undefined
Explanation:
The typeof operator has a special safety feature where operating on an undeclared variable identifier yields string "undefined" without throwing ReferenceError.

74. What will `console.log(letVar)` output given: `console.log(letVar); let letVar = 10;`?

a) undefined
b) 10
c) ReferenceError
d) null
Correct Answer: c) ReferenceError
Explanation:
Variables declared with let are hoisted but remain uninitialized in the Temporal Dead Zone (TDZ); accessing them before initialization throws ReferenceError.

75. What will `console.log(varVar)` output given: `console.log(varVar); var varVar = 10;`?

a) undefined
b) 10
c) ReferenceError
d) null
Correct Answer: a) undefined
Explanation:
Declarations with var are hoisted to the top of their scope and initialized to value undefined during execution setup.

76. What is the output of `console.log(+true)`?

a) 1
b) true
c) NaN
d) TypeError
Correct Answer: a) 1
Explanation:
Unary plus operator (+) forces type conversion of boolean operand true to numeric value 1.

77. What is the output of `console.log(+false)`?

a) 0
b) false
c) NaN
d) TypeError
Correct Answer: a) 0
Explanation:
Unary plus operator (+) forces type conversion of boolean operand false to numeric value 0.

78. What is the output of `console.log(+"")`?

a) 0
b) NaN
c) undefined
d) TypeError
Correct Answer: a) 0
Explanation:
Unary plus operator (+) coerces empty string literal "" to number 0.

79. What is the output of `console.log(+"Hello")`?

a) NaN
b) 0
c) Hello
d) TypeError
Correct Answer: a) NaN
Explanation:
Unary plus operator (+) fails to convert non-numeric text string "Hello" to valid number, returning NaN.

80. What does string immutability in JavaScript imply?

a) String variables cannot be reassigned new string values
b) Individual character values within an existing string primitive instance cannot be altered directly
c) Strings cannot be concatenated with other types
d) Strings are stored as objects on the heap
Correct Answer: b) Individual character values within an existing string primitive instance cannot be altered directly
Explanation:
Primitive string values are immutable; operations that alter strings return newly generated string primitives.

81. What happens when executing `let str = "hello"; str[0] = "j"; console.log(str);`?

a) "jello"
b) "hello"
c) TypeError in non-strict mode
d) undefined
Correct Answer: b) "hello"
Explanation:
Primitives are immutable. Direct bracket index assignments on primitive strings fail silently (or throw TypeError in strict mode) leaving the original unchanged.

82. What is the output of `console.log(typeof (100n))`?

a) bigint
b) number
c) integer
d) object
Correct Answer: a) bigint
Explanation:
100n is a BigInt primitive value, so calling typeof returns string identifier "bigint".

83. Which of the following correctly describes dynamic typing in JavaScript?

a) Variables are bound to specific static types at declaration time
b) Variables hold values, and types are associated with values rather than the variables themselves
c) Variables automatically convert to objects at runtime
d) Variables cannot change data types after initial assignment
Correct Answer: b) Variables hold values, and types are associated with values rather than the variables themselves
Explanation:
JavaScript is dynamically typed, meaning variables can be reassigned values of completely different data types during execution.

84. What is the output of `let x = 5; x = "hello"; console.log(typeof x);`?

a) number
b) string
c) object
d) undefined
Correct Answer: b) string
Explanation:
Reassigning variable identifier x to string "hello" changes the type of value stored in x to string.

85. Which global constant represents safe integer bounds lower limits in JS?

a) Number.MIN_SAFE_INTEGER
b) Number.MIN_VALUE
c) Number.LOWEST_INTEGER
d) -Infinity
Correct Answer: a) Number.MIN_SAFE_INTEGER
Explanation:
Number.MIN_SAFE_INTEGER represents -(2^53 - 1), or -9007199254740991.

86. What is the value of `Number.MIN_VALUE` in JavaScript?

a) The most negative number expressible in JS
b) The smallest positive floating point number greater than 0
c) -(2^53 - 1)
d) -Infinity
Correct Answer: b) The smallest positive floating point number greater than 0
Explanation:
Number.MIN_VALUE is approximately 5e-324, representing smallest positive value closest to zero, not most negative number.

87. What is the output of `console.log(typeof Math)`?

a) math
b) function
c) object
d) undefined
Correct Answer: c) object
Explanation:
Math is a built-in standard global namespace Object holding mathematical properties and methods.

88. What is the output of `console.log(typeof Math.PI)`?

a) number
b) float
c) constant
d) object
Correct Answer: a) number
Explanation:
Math.PI holds standard double-precision floating point number primitive, returning "number".

89. What will `console.log(1 / -0)` evaluate to?

a) -Infinity
b) Infinity
c) -0
d) NaN
Correct Answer: a) -Infinity
Explanation:
JavaScript supports signed zeroes (-0 and +0); dividing positive 1 by -0 yields numeric -Infinity.

90. What is the result of `console.log(Object.is(-0, +0))`?

a) true
b) false
c) undefined
d) TypeError
Correct Answer: b) false
Explanation:
Object.is static method distinguishes signed zeros, evaluating Object.is(-0, +0) to false.

91. What is the result of `console.log(-0 === +0)`?

a) true
b) false
c) TypeError
d) undefined
Correct Answer: a) true
Explanation:
The strict equality operator (===) explicitly treats signed zeros -0 and +0 as equal values.

92. What is the result of `console.log(Object.is(NaN, NaN))`?

a) true
b) false
c) undefined
d) TypeError
Correct Answer: a) true
Explanation:
Unlike triple equals (===), Object.is evaluates NaN values as identical to each other, returning true.

93. What is the result of `console.log(NaN === NaN)`?

a) true
b) false
c) undefined
d) TypeError
Correct Answer: b) false
Explanation:
In IEEE 754 and JavaScript equality semantics, NaN is unequal to any value including itself.

94. Which keyword limits variable lifetime and scope exclusively to enclosing block execution context?

a) var
b) let
c) global
d) extern
Correct Answer: b) let
Explanation:
The 'let' keyword specifies block scoping rules, isolating variables inside block boundaries.

95. What will `console.log(a)` output when executing: `{ var a = 5; } console.log(a);`?

a) 5
b) ReferenceError
c) undefined
d) null
Correct Answer: a) 5
Explanation:
Variables declared using 'var' ignore arbitrary block enclosures `{}` and leak to enclosing function or global scope.

96. What will `console.log(a)` output when executing: `{ let a = 5; } console.log(a);`?

a) 5
b) ReferenceError
c) undefined
d) null
Correct Answer: b) ReferenceError
Explanation:
Because 'let' is block-scoped, variable `a` is inaccessible outside enclosing block bounds, throwing ReferenceError.

97. What will `console.log(typeof JSON)` output?

a) json
b) object
c) function
d) string
Correct Answer: b) object
Explanation:
JSON is a global namespace object in JavaScript containing methods like parse() and stringify().

98. What happens when you execute `const obj = { a: 1 }; obj.a = 2; console.log(obj.a);`?

a) Outputs 2
b) Throws TypeError
c) Outputs 1
d) Throws ReferenceError
Correct Answer: a) Outputs 2
Explanation:
The const declaration prevents reassigning the identifier binding `obj`, but object properties remain fully mutable.

99. What happens when executing `const obj = { a: 1 }; obj = { a: 2 };`?

a) Object successfully updated
b) Throws TypeError
c) Throws SyntaxError
d) Fails silently
Correct Answer: b) Throws TypeError
Explanation:
Reassigning a variable declared with const to a new object memory reference throws a TypeError.

100. What will `console.log("2" > 1)` evaluate to?

a) true
b) false
c) NaN
d) TypeError
Correct Answer: a) true
Explanation:
Relational comparison operators force string "2" to number 2, making numeric evaluation 2 > 1 return true.

101. What will `console.log("2" > "12")` evaluate to?

a) true
b) false
c) NaN
d) TypeError
Correct Answer: a) true
Explanation:
When comparing two strings, JavaScript performs lexicographical comparison based on character Unicode values. "2" comes after "1", making "2" > "12" true.
← Previous: JavaScript This Keyword & Scope MCQs
Next →: Latest C++ Basics MCQs
Latest C++ Basics MCQs

Latest C++ Basics MCQs

Created by Bjarne Stroustrup as an extension of the C programming language, C++ is a powerful, high-performance, statically typed language…

By MCQs Generator
Java Control Flow / If Else MCQs

Java Control Flow / If Else MCQs

Control flow statements in Java determine the exact order in which code instructions and expressions execute during runtime. By default,…

By MCQs Generator
JavaScript Functions MCQs

JavaScript Functions MCQs

Functions are the primary building blocks of JavaScript applications, enabling code modularity, encapsulation, and reuse. In JavaScript, functions are first-class…

By MCQs Generator