February 2018
Intermediate to advanced
298 pages
8h 22m
English
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).
Read now
Unlock full access