JavaScript
What is JavaScript?
Welcome to the MDN beginner's JavaScript course! In this article we will look at JavaScript from a high level, answering questions such as "What is it?" and "What can you do with it?", and making sure you are comfortable with JavaScript's purpose.
JavaScript is a scripting or programming language that allows you to implement complex features on web pages — every time a web page does more than just sit there and display static information for you to look at — displaying timely content updates, interactive maps, animated 2D/3D graphics, scrolling video jukeboxes, etc. — you can bet that JavaScript is probably involved. It is the third layer of the layer cake of standard web technologies, two of which (HTML?and?CSS) we have covered in much more detail in other parts of the Learning Area.
The three layers build on top of one another nicely. Let's take a simple text label as an example. We can mark it up using HTML to give it structure and purpose
Try clicking on this last version of the text label to see what happens (note also that you can find this demo on GitHub — see the?source code, or?run it live)!
JavaScript can do a lot more than that — let's explore what in more detail.
领英推荐
The core client-side JavaScript language consists of some common programming features that allow you to do things like:
What is even more exciting however is the functionality built on top of the client-side JavaScript language. So-called?Application Programming Interfaces?(APIs) provide you with extra superpowers to use in your JavaScript code.
APIs are ready-made sets of code building blocks that allow a developer to implement programs that would otherwise be hard or impossible to implement. They do the same thing for programming that ready-made furniture kits do for home building — it is much easier to take ready-cut panels and screw them together to make a bookshelf than it is to work out the design yourself, go and find the correct wood, cut all the panels to the right size and shape, find the correct-sized screws, and?then?put them together to make a bookshelf.
They generally fall into two categories.
Browser APIs?are built into your web browser, and are able to expose data from the surrounding computer environment, or do useful complex things. For example:
Note:?Many of the above demos won't work in an older browser —?