Various JS environments (like browser JS engines, Node.js, etc.) add
APIs into the global scope of your JS programs that give you
environment-specific capabilities, like being able to pop an
alert-style box in the user's browser.
In fact, a wide range of JS-looking APIs, like fetch(..),
getCurrentLocation(..), and getUserMedia(..), are all web APIs that
look like JS. In Node.js, we can access hundreds of API methods from
various built-in modules, like fs.write(..).
Another common example is console.log(..) (and all the other console.*
methods!). These are not specified in JS, but because of their
universal utility are defined by pretty much every JS environment,
according to a roughly agreed consensus.
So alert(..) and console.log(..) are not defined by JS. But they look
like JS. They are functions and object methods and they obey JS syntax
rules. The behaviors behind them are controlled by the environment
running the JS engine, but on the surface they definitely have to
abide by JS to be able to play in the JS playground.
You-Dont-Know-JS - Chapter 1