• explicit coercion of a symbol to a string is allowed, but implicit coercion of the same is disallowed and throws an error.
var s1 = Symbol( "cool" );
String( s1 );                   // "Symbol(cool)"

var s2 = Symbol( "not cool" );
s2 + "";                        // TypeError
  • symbol values cannot coerce to number at all (throws an error either way), but strangely they can both explicitly and implicitly coerce to boolean (always true).
扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄