JavaScript : Function isOneOf(obj, types)