in order to solve this problem: [] + [] = "
,
excuse me ToPrimitive ([])
how to convert hint to string
The abstract operation ToPrimitive takes an input argument and an optional argument PreferredType. The abstract operation ToPrimitive converts its input argument to a non-Object type. If an object is capable of converting to more than one primitive type, it may use the optional hint PreferredType to favour that type. Conversion occurs according to the following algorithm:
- Assert : input is an ECMAScript language value .
-
If Type (input) is Object, then
- If PreferredType is not present, let hint be
"default"
. - Else if PreferredType is hint String, let hint be
"string"
. - Else PreferredType is hint Number, let hint be
"number"
. - Let exoticToPrim be? GetMethod (input, @ @ toPrimitive).
-
If exoticToPrim is not undefined, then
- If hint is
"default"
, set hint to"number"
. - Return? OrdinaryToPrimitive (input, hint).
- If PreferredType is not present, let hint be
- Return input.