There is no existing spatial query tool provided by JS API. You can use the draw toolbar to draw a graphic. Then use it to perform spatial query using either QueryTask or featureLayer.queryFeatures.
Here are two samples you can refer to:
Draw toolbar: http://developers.arcgis.com/en/javascript/samples/toolbar_draw/
Spatial Query sample: https://developers.arcgis.com/en/javascript/jssamples/fl_selectfeatures.html