[Discussion] Consider using stricter brand checks than just Symbol.toStringTag? #70
Labels
question
Further information is requested
Content-Length: 225602 | pFad | http://github.com/mesqueeb/is-what/issues/70
1B
Right now if you use something like a math library that defines a
Symbol
class for math operations and doisSymbol()
on it, there is a serious non-zero chance that it will return true! 😱This happens because
isSymbol()
relies onSymbol.toStringTag
viaObject#toString()
to "sniff" the type. There are other more robust ways for this particular type, though, and I think they should be used.Example:
Or, you could get fancier and do a branch check on the
.description
getter! If it throws, it's not a symbol.The text was updated successfully, but these errors were encountered: