It matches an optional slash. The slash needs to be escaped because slashes also serve as delimiters in JavaScript regex literals.
It's not really useful to surround it with capturing parentheses. \/?
would work as well (unless you later on want to check whether you have matched an opening or a closing tag).