What is JS
JavaScript is a fully independent language with its own specification called ECMAScript.
- Ecma International is an industry association dedicated to standardization of information and communication systems.
- For each new specification ECMA provides a standard specification and a committee in case of JS the standard is ECMA-262 and the committee that works on ECMA-262 is called Technical Committee 39 (TC39).
- ECMA-262 specifies a general-purpose scripting language. The language is called ECMAScript.
- The ECMAScript standard defines the rules, details, and guidelines that the scripting language must observe to be considered ECMAScript compliant.
- Ecma used the term ECMAScript to talk about the official language because oracle owns trademark for the term JavaScript.
- The ECMAScript specification is a blueprint for creating a scripting language. JavaScript is an implementation of that blueprint.
- Languages such as ActionScript, JavaScript, JScript all use ECMAScript as its core.
<aside>
💡 JavaScript was originally developed in 11 days under the name Mocha, then LiveScript, and finally renamed to JavaScript.
</aside>
JavaScript can execute not only in the browser, but also on the server, or actually on any device that has a special program called the JavaScript engine.
- The engine (embedded if it’s a browser) reads/parses the script. Then it converts (“compiles”) the script to the machine language. And then the machine code runs, pretty fast.
- The engine applies optimizations at each step of the process. It even watches the compiled script as it runs, analyzes the data that flows through it, and further optimizes the machine code based on that knowledge, this is called just-in-time-compilation (JIT).
Modern JavaScript is a “safe” programming language. It does not provide low-level access to memory or CPU, because it was initially created for browsers which do not require it.
JavaScript’s capabilities greatly depend on the environment it’s running in (JS runtime).
- Node.js supports functions that allow JavaScript to read/write arbitrary files, perform network requests, etc.
- In-browser JavaScript can do everything related to webpage manipulation, interaction with the user, and the webserver.
JavaScript’s abilities in the browser are limited for the sake of the user’s safety, to prevent webpage from accessing private information or harming the user’s data.
JavaScript on a webpage may not read/write arbitrary files on the hard disk, copy them or execute programs. It has no direct access to OS functions. (Requires user access).