Way in script to check if any event exists at an (x,y) position?

As the title; I want to poll via script to check if an event exists on a specific (x,y).

Like I want to call a function or a couple of statements where I can check this via script.

I know there are various methods by which you can poll individual events you know for their position, or various other ways of working. However, it would need to be specifically this way, i.e.

doesEventExist(x,y) - returns TRUE/FALSE

It's okay if I need to do it in a couple of statements or in a slightly roundabout way, but I'm working with a spawning system so it's not quite as straightforward as with usual static maps.
no need for a script - that is a basic function of the event command "get location info".
It returns the ID of the event if there is one, or zero if not.

If you absolutely need that as script, check for the list of the script equivalents of event commands.
JavaScript:
$gameMap.eventsXy(x, y).length > 0
Thanks, both of you - this is a huge help.
Thread closed

Original thread: https://forums.rpgmakerweb.com/threads/way-in-script-to-check-if-any-event-exists-at-an-x-y-position.142085/