We are still actively working on the spam issue.


From InstallGentoo Wiki
Jump to: navigation, search
Unofficial logo.

JavaScript (or ECMAScript) is a scripting language that was originally designed for use in the Netscape web browser, but later became a web standard. JavaScript has traditionally been confined to the browser to add interactivity to web pages, but in recent years has been adopted for use in desktop applications through technologies such as GJS and Electron and for server-side use, primarily due to Node.js, but also Rhino.

Creator Brendan Eich has been quoted as saying that Javascript "had to ‘look like Java’ only less so, be Java's dumb kid brother or boy-hostage sidekick. Plus, it had to be done in ten days or something worse than JavaScript would have happened."

The language was originally named LiveScript, renamed to JavaScript before its original release in Netscape Navigator 2.0, and is referred to as ECMAScript usually for the purposes of standardisation aside other uses possibly due to the fact that "JavaScript" is a trademark of Oracle.

In the last few years, since the release of Node.js, a project that uses Chromium's V8 JavaScript runtime and includes a set of APIs designed for writing event-based asynchronous servers, the popularity of JavaScript has boomed, with Stack Overflow's 2016 survey of developers finding that 55% of developers surveyed used JavaScript, while it grew impetus for the often idiosyncratic language to be improved (see #ECMAScript 6+).



Many people hate JavaScript. When it began, it was just a neat sort of thing that allowed pages to be animated. However, later on for a number of reasons, including the rise of Web 2.0, JavaScript became a primary element of RUE websites, causing a page that would otherwise be 1MB long in memory and transmission terms to be 40MB with JavaScript.

The language itself

JavaScript as a language is somewhat unsound. Possibly as a result of the language originally being written within 10 days, for a very long time JavaScript only had simple function-level scoping, instead of lexical scoping (within blocks) used by almost every other popular programming language (bar the Bourne shell and Emacs Lisp). JavaScript's typing behaviour is clumsy, making many insane coercions between types compared to saner dynamic/duck typed languages such as Python; this problem led to new === and !== equality operators that only allow comparison between two values of the same type. JavaScript also has no standard library; it relies on the often disparate APIs in browsers (or Node), contributing to the cross-browser incompatiblity mess.

ECMAScript 6+

In recent years, there has been a new initiative to add missing features to the language and fix some of it's problems. Previously these efforts were hampered by Microsoft, but in 2015 ECMAScript 6 was finally finished and standardised as ECMAScript 2015.

The most important and significant introductions include:

  • Lexical scoping - ECMAScript 2015 introduces two new keywords, let and const to replace var, as such:
    let x = 1
      let x = 2
    const uses the same scoping rules as let, but causes the name to be unable to be assigned to another value.
  • Function expressions, akin to lambdas and closures in other programming languages, are common in JavaScript, for example, as callbacks as arguments in asynchronous functions and event handlers. ECMAScript 2015 introduces a new, more concise syntax for function expressions called arrow functions.
    let a = function (a, b, c) {
      return a + b + c;
    let b = (a, b, c) => {
      return a + b + c;
    let nums = [1, 2, 3, 4, 5, 6];
    let evens = nums.filter(elem => elem % 2 === 0); // Function expressions with one parameter or one expression need not use braces
  • JavaScript once only had range-based C style for loops. An extension, for (prop in obj), loops over the enumerable properties of obj, making it unsuitable for looping over collections. ECMAScript 2015 introduces a new for (elem of array) pattern that iterates over the elements of collections, akin to for loops in Python.

Other new additions include standard functions such as Array.from for converting pseudo-array types such as NodeList and HTMLCollection, classes as an alternative to prototype-based object oriented programming, template strings, the ... operator which acts like *args in Python, symbols and Promises, a new asynchronous code paradigm as an alternative to callback hell.

Not all ES2015 features have been implemented into browsers and JavaScript runtimes. The progress of implementation has been tabled up here.


Security risks in JavaScript are extensive, through flaws in the language and exploits in JavaScript runtimes. JavaScript can also be used to make a keylogger.

Software freedom

The method in which JavaScript is executed upon page load without the user's consent is an affront to software freedom - the Javascript Trap. LibreJS is a web plugin designed by the FSF to block non-free JavaScript.