Optiv Interview Question

How does an nmap port scan work?