public virtual object DefaultValue(ValueHint hint) { object toString; object valueOf; if (hint == ValueHint.String) { toString = Get("toString"); if (toString is IFunction) return (toString as IFunction).Call(this, null); valueOf = Get("valueOf"); if (valueOf is IFunction) return (valueOf as IFunction).Call(this, null); throw new ShouldThrowTypeError(); } valueOf = Get("valueOf"); if (valueOf is IFunction) return (valueOf as IFunction).Call(this, null); toString = Get("toString"); if (toString is IFunction) return (toString as IFunction).Call(this, null); throw new ShouldThrowTypeError(); }
internal static object ToPrimitive(object obj, ValueHint hint = ValueHint.None) { if (obj == null || obj is Js.Undefined || obj is bool || obj is double || obj is string) return obj; if (obj is IObj) return ((IObj)obj).DefaultValue(hint); return obj.ToString(); }