Is it possible to export a featureset (resulting from a query) to a hosted feature layer in ArcGIS Online and/or an ArcGIS Enterprise Portal using ArcGIS JavaScript?
Potentially just need some clarification about what you're trying to do.
You can do a query against a feature layer and then just pipe those results into an ApplyEdits against another layer in your AGOL or Enterprise using Javascript if that's what you're asking.
@JamesIng Great mention.
It would be of interest to create a new hosted feature layer containing a featureset resulting from a query (in this case a spatial query).
If it is not possible to create a new hosted feature layer using ArcGIS JavaScript, using ApplyEdits to capture the resulting featureset would be of interest as well.
If you want to create a brand new feature layer or service you can't do that directly through the Javascript API.
Instead you'll want to use the REST API.
https://developers.arcgis.com/rest/users-groups-and-items/create-service/
Once you have a hosted service you can then do a spatial query and do an applyEdits using the Javascript API from that query to your new service.
Apply Edits
https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#applyEdi...
Thank you for the resources!
What might it look like to utilize the REST API within an ArcGIS JavaScript application to create a new hosted feature layer? Do you happen to have an example?