I was just looking over the Esri JS API documentation and the Esri REST API documentation at query operations. I noticed that the query REST endpoint is called by the FeatureLayer.queryFeatures function. The query REST endpoint has an option for returnDistinctValues to get a list of unique values in a field. Why isn't this an option for the Query object in the JS API. It's always a lot of trouble to have to sift through the results of a query to get the unique values and it's even worse when there are more values than are returned by a single query.
var queryTask = new QueryTask(dataURL + "?returnDistinctValues=true");
Kudos to John and Andrew for the workarounds. A few follow-up notes:
that particular query parameter has not yet been added to our JavaScript API.
[NIM091580: Add 'returnDistinctValues' property to the esri.tasks.Query class.]
until it is included, you might consider using esriRequset.setRequestPreCallback() to catch the request immediately before it is issued and modify it as needed.