> The current ES6 draft defines its like this:
>
> 15.2.4.2 Object.prototype.toString ( )
>
> When the toString method is called, the following steps are taken:
>
> If the this value is undefined, return "[object Undefined]".
> If the this value is null, return "[object Null]".
> Let O be the result of calling ToObject passing the this value as the
> argument.
> If O has a [[NativeBrand]] internal property, let tag be the
> corresponding value from the Table 23.
> Else, let tag be the string value "Object".
> Return the String value that is the result of concatenating the three
> Strings "[object ", tag, and "]".
> Table 23 — Tags for Classified Native Objects
>
> [[NativeBrand]] Value
> tag Value
> NativeFunction
> "Function"
> NativeArray
> "Array"
> StringWrapper
> "String"
> BooleanWrapper
> "Boolean"
> NumberWrapper
> "Number"
> NativeMath
> "Math"
> NativeDate
> "Date"
> NativeRegExp
> "RegExp"
> NativeError
> "Error"
> NativeJSON
> "JSON"
> NativeArguments
> "Arguments"
Not sure that it makes sense (backward compatibility...), but one could handle
primitive booleans, numbers, and strings differently:
Currently:
$ Object.prototype.toString.call(true)
'[object Boolean]'
Alternative:
$ Object.prototype.toString.call(true)
'[primitive boolean]'
--
Dr. Axel Rauschmayer
[email protected]
home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss