When JavaScript was created in 1995, it was influenced by several programming languages:
function
).
onclick
in web browsers.
With ECMAScript 6, new influences came to JavaScript:
const
.
These are a few traits of the language:
Its syntax is part of the C family of languages (curly braces, etc.).
It is a dynamic language: most objects can be changed in various ways at runtime, objects can be created directly, etc.
It is a dynamically typed language: variables don’t have fixed static types and you can assign any value to a given (mutable) variable.
It has functional programming features: first-class functions, closures, partial application via bind()
, etc.
It has object-oriented features: mutable state, objects, inheritance, classes, etc.
It often fails silently: see the next subsection for details.
It is deployed as source code. But that source code is often minified (rewritten to require less storage). And there are plans for a binary source code format.
JavaScript is part of the web platform – it is the language built into web browsers. But it is also used elsewhere – for example, in Node.js, for server things, and shell scripting.
JavaScript engines often optimize less-efficient language mechanisms under the hood. For example, in principle, JavaScript Arrays are dictionaries. But under the hood, engines store Arrays contiguously if they have contiguous indices.
JavaScript often fails silently. Let’s look at two examples.
First example: If the operands of an operator don’t have the appropriate types, they are converted as necessary.
> '3' * '5'
15
Second example: If an arithmetic computation fails, you get an error value, not an exception.
> 1 / 0
Infinity
The reason for the silent failures is historical: JavaScript did not have exceptions until ECMAScript 3. Since then, its designers have tried to avoid silent failures.
These are a few tips to help you get started with JavaScript:
Take your time to really get to know this language. The conventional C-style syntax hides that this is a very unconventional language. Learn especially the quirks and the rationales behind them. Then you will understand and appreciate the language better.
===
to determine if two values are equal, never ==
.”
Language tools make it easier to work with JavaScript. For example:
Get in contact with the community:
Read books and blogs. Much material is free online!