If NewTarget is not undefined, throw a TypeError exception.
Note: the Symbol Constructor is not intended to be used with the new operator(not the target for new)
If description is undefined, let descString be undefined; Else, let descString be ? ToString(description).
Return a new unique Symbol value whose [[Description]] value is descString.
Note: the Symbol() function returns a Symbol type instead of a Symbol object
Symbol Prototype Object
abstract operation thisSymbolValue(value)
If Type(value) is Symbol, return value.
If Type(value) is Object and value has a [[SymbolData]] internal slot
then Return value.[[SymbolData]] //a Symbol Object
Throw a TypeError exception.
Example
mySymbol = Symbol( "my symbol" )
// Object() performs a type conversion when called as a function rather than as a constructor.
mySymObj = Object(mySymbol)
console.log(mySymObj.toString()) // Symbol(my symbol)
No comments:
Post a Comment