JavaScript is a dynamic functional object-oriented programming language that can be used for
Enriching a web page by
generating browser-specific HTML content or CSS styling,
inserting dynamic HTML content,
producing special audio-visual effects (animations).
Enriching a web user interface by
implementing advanced user interface components,
validating user input on the client side,
automatically pre-filling certain form fields.
Implementing a front-end web application with local or remote data storage.
Implementing a front-end component for a distributed web application with remote data storage managed by a back-end component, which is a server-side program that is traditionally written in a server-side language such as PHP, Java or C#, but can nowadays also be written in JavaScript with NodeJS.
Implementing a complete distributed web application where both the front-end and the back-end components are JavaScript programs.
The version of JavaScript that is currently fully supported by web
browsers is called "ECMAScript 5.1", or simply "ES5", but the next two versions, called "ES6" and
"ES7" (or "ES 2015" and "ES 2016"), are already partially supported by
current browsers and back-end JS environments. In fact, in May 2017, ES6 is
fully supported in non-mobile browsers, except its important new
module
concept.
JavaScript is object-oriented,
but in a different way than classical OO programming languages such as
Java and C++. In JavaScript, classes, unlike objects and functions, are
not first-class citizens. Rather, classes have to be defined by following
some code pattern in the form of special JS objects: either as constructor functions (possibly using the
syntactic sugar of ES6 class
declarations) or as factory objects.
However, objects can also be created without instantiating a class, in which case they are untyped, and properties as well as methods can be defined for specific objects independently of any class definition. At run time, properties and methods can be added to, or removed from, any object and class. This dynamism of JavaScript allows powerful forms of meta-programming, such as defining your own concepts of classes and enumerations (and other special datatypes).
Good open access books about JavaScript are
Speaking JavaScript, by Dr. Axel Rauschmayer.
Eloquent JavaScript, by Marijn Haverbeke.