You can call
getUnit() on a space to retrieve the unit located there (but keep in mind that not all spaces have units on them):
const unit = space.getUnit();
You can call methods on a unit to know more about it.
Here are the various methods that are available to you:
Determines if the unit is bound.
(boolean): Whether this unit is bound or not.
Determines if the unit is an enemy.
(boolean): Whether this is an enemy unit or not.