I did find Find Nearest endpoint for JS 3.xx FindNearest | API Reference | ArcGIS API for JavaScript 3.29. But I am using JavaScript api 4.12 and don't see any documentation wrt. to this endpoint in the 4.xx documentation. Was it re-named or deprecated for a reason? If yes, is there any other way to solve this problem programmatically?