What is JavaScript?
You can’t get very far in tech without running smack into javascript. It’s a programming language that makes the web what it is and powers features you likely take for granted, like your Facebook timeline automatically updating on your screen or Google suggesting search terms based on the letters you start typing.
JavaScript is a single-threaded, interpreted, and compiled programming language that is also known as a scripting language for webpages. It is a declarative language with both imperative and functional elements. It is a dynamically typed language, meaning that variables can change their types throughout the course of a program.
Like many languages, javascript includes built-in data structures and functions that make up its standard library. Variables can be created by using object literals or constructor function calls. They can hold objects and numbers, among other things. Data structures are essentially collections of variables that can be manipulated together in the same way as a list. For example, a data structure might consist of a map of integers and a list of strings. In addition to data structures, javascript has functions, which are a special type of data structure that can be called.
Unlike some low-level programming languages, which require that memory be manually allocated and deallocated, javascript uses a garbage collector to manage memory allocation. Every time a variable is created, the garbage collector finds a suitable space in the memory heap to store the object. It keeps track of how many references to each object it has and when those reference count drops to zero, the garbage collector frees up that object’s memory so that it can be reassigned to another object or variable.
Since javascript is used to run in web browsers, it has a special set of features that allow it to travel through the element family tree, or DOM, on an HTML page and access, modify, add, or delete elements. It can only do this, however, if the element has been interpreted by the browser.
While there are other languages that can be used to create webpages, javascript is unique in that it’s the only one that can be fully integrated with HTML/CSS and run in web browsers. Because of this, it has a renaissance period in the past few years thanks to open-source libraries and communities that have developed around it such as jQuery, Prototype, and Dojo Toolkit. These libraries are used to enable features such as Ajax, which allows data to be loaded and updated on a web page without requiring a full page reload. In addition to this, javascript is often used in conjunction with APIs (Application Programming Interfaces) for remote communication with other software systems. This is especially common in mobile apps where javascript provides an important means for users to interact with those systems from the user’s browser.