JavaScript
JavaScript is a programming or scripting language that allows you to implement complex functions in web pages, every time a web page does more than sit there and display static information for you to see, it shows timely content updates, interactive maps , 2D / 3D Graphics animation, video player scrolling, etc., you can bet that JavaScript is probably involved.
It’s the third layer on the cake of standard web technologies.
What can I do with JavaScript ?
The core of the client-side JavaScript language consists of some common programming features that allow you to do things like:
- Store useful values within variables.
- Operations on text fragments (known as "strings" in programming).
- execute code in response to certain events that occur on a web page.
However, what is even more exciting is the functionality built on top of the client-side JavaScript language.
So-called application programming interfaces (APIs) give you additional superpowers to use in your JavaScript code.
APIs are ready-to-use sets of code building blocks that allow a developer to implement programs that would otherwise be difficult or impossible to implement.
They do the same for programming as prefab home building kits - it is much easier to take pre-cut panels and screw them together to make a bookcase than to come up with the design yourself, than to go and find the right wood, cut all the panels the correct size and shape, find the correct size screws, then put them together to make a bookcase.
Browser APIs are built into your web browser and can expose data from the surrounding computing environment or perform complex and useful tasks.
For example:
- The DOM (Document Object Model) API allows you to manipulate HTML and CSS, create, delete and change HTML, dynamically apply new styles to your page, etc. Every time you see a popup appear on a page, or some new content is shown (as we saw earlier in our simple demo), for example, that's the DOM in action.
- The Geolocation API retrieves geographic information. This is how Google Maps can find your location and plot it on a map.
- The Canvas and WebGL APIs allow you to create 2D and 3D motion graphics. People are doing amazing things with these web technologies - see Chrome experiments and webglsamples.
- Audio and video APIs like HTMLMediaElement and WebRTC let you do really cool things with multimedia, like play audio and video directly on a web page, or take video from your webcam and display it on someone else's computer.
An interpreted Language
JavaScript is a lightweight interpreted programming language.
The web browser receives the JavaScript code in its original text form and executes the script from there.
From a technical point of view, most modern JavaScript interpreters use a technique called real-time compilation to improve performance; JavaScript source code is compiled into a faster binary format while the script is in use, so that it can be executed as quickly as possible.
However, JavaScript is still considered an interpreted language, since compilation is handled in the runtime environment, rather than before.