public static bool IsPrimitive(object obj) { return obj == null || obj == Undefined.instance || (obj is Number) || (obj is string) || (obj is bool); }