The new operator

You cannot apply the new operator to the Symbol() function. The Symbol() function detects whether it's being used as a constructor, and if true, it then throws an exception. Here is an example to demonstrate this:

try {  let s = new Symbol(); //"TypeError" exception}catch(e) {  console.log(e.message); //Output "Symbol is not a constructor"}

But the JavaScript engine can use the Symbol() function internally as a constructor to wrap a symbol in an object. Therefore, s will be equal to object(s).

All primitive types introduced from ES6 onward will not allow their constructors to be invoked manually.

Get Learn ECMAScript - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.