Endstops are used so that the machine using them to know where the ends of an area is. The opto endstop uses a Transmissive Opto Sensor and a flag that tells the machine that the limit is reached.
A opto endstop also needs a flag to break to break the optical sensor, but that is a later thing to do; also needs a bunch of cables for the installation…