What is Javascript?

You won’t get very far in tech without running smack into javascript, but it’s not as scary as it sounds. It’s the technology that powers a lot of web features you use daily, like when your Facebook timeline updates or Google suggests search terms based on the first few letters you type. You’ll also find javascript in many in-browser games.

JS is written in human-readable syntax that includes alphabets and numbers, but computers can’t understand this code by itself. That’s why javascript has an engine, or an environment, that interprets the language and turns it into machine code.

To do this, the engine reads the javascript code and saves it into a data structure called an abstract syntax tree. This tree contains information about the javascript elements like variables, functions and classes. The AST also checks for errors and creates the machine code. The V8 engine is the default JS engine used by most browsers, but there are other engines available.

Then the engine translates the AST into the javascript execution environment, which is how your browser actually executes the script. It also checks to see if the script has been loaded and executed before. If it hasn’t, the engine will load and execute the JS script.

Once your javascript is loaded, the engine runs it by using its runtime system. The runtime system uses a small set of data types, including numbers (integer and floating point), booleans and strings. It also supports a prototype-based object model and functional programming by making functions first-class objects that can be created via expressions and invoked as properties of other objects.

One important feature of the runtime system is event delegation, which allows multiple objects to share the same event listeners. This reduces the number of events that are tracked by the browser and helps improve performance. Another runtime feature is the arrow function operator, which lets you create a function that acts as if it were a method on an existing class or object property. This is very useful for creating callback functions that do something when the object they’re attached to gets triggered.

In addition to the runtime system, javascript provides several other features that make it more efficient and powerful than other languages. For example, it supports multi-line comments that begin with a double forward slash (//). It also has an interactive console, which gives you a mini-editor where you can enter your code, press Enter to have the code executed, and then continue typing. The console also offers tools like a debugger, which is especially helpful when you’re writing complex programs that are hard to test and debug with the standard HTML editor.