How is JavaScript injection related to XSS?
XSS is the most common way JavaScript injection happens, injecting script through unescaped input. But injection can also occur without a classic XSS bug: through a compromised third-party script, unsafe evaluation of dynamic data, or a tricked user pasting code into the console. XSS is one route to JavaScript injection, not the only one.