The JavaScript environment
3 May 2022 (Updated 24 May 2022)
All JavaScript code runs in an environment such as a web browser (e.g., Chrome, Firefox) or a server-side runtime (e.g., Node.js, Deno). These environments provide essential components without which JavaScript wouldn’t be very useful. Here are the main components:
- Runtime engine (e.g., V8, Chakra, SpiderMonkey): parses and executes JavaScript source code. Manages memory allocation and the call stack.
- APIs: this will be dependent on the environment. For example, browsers provide
document
,XMLHttpRequest
,setTimeout
, etc. Node.js providesfs
,process
,buffer
, etc. Electron providesclipboard
,systemPreferences
, etc. - Event loop: simulates concurrency when combined with other APIs (e.g.,
setTimeout
,XMLHttpRequest
) and the callback queue. - Callback queue: list of callbacks waiting to be added to the call stack.
Tagged:
JavaScript
Thanks for your comment 🙏. Once it's approved, it will appear here.
Leave a comment