MCQ Single Best Answer Easy

QWhat is the result of the following code?
var sym = Symbol("foo");
console.log(typeof sym);

ID: #4893 JavaScript Operator MCQ 205 views
Question Info
#4893Q ID
EasyDifficulty
JavaScript Operator MCQTopic

Choose the Best Option

Click any option to instantly check if you're correct.

  • A symbol
  • B number
  • C string
  • D boolean
Correct Answer: Option A

Explanation

The Symbol data type in JavaScript is a primitive data type that represents a unique identifier.
Symbols are created using the Symbol constructor, which takes an optional string description as an argument.
In this case, a new symbol is created using the Symbol constructor, with the string "foo" as the description.
The typeof operator is called on the symbol, which returns the string "symbol".

Share This Question

Challenge a friend or share with your study group.