TIL JS specifics vs JS-looking APIs
POSTED ON:
TAGS: javascript you-dont-know-js
Snippet from the book:
Is this code a JS program?
`alert("Hello, JS!");`
Depends on how you look at things. The alert(..) function shown here is not included in the JS specification, but it is in all web JS environments. Yet, you won't find it in Appendix B, so what gives?
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(..).
Via You Don't Know JS (2nd edition)
Related TILs
Tagged: javascript