● Variables provide useful data. In the example, users are asked to input their names and then that information is stored in a variable named name.
● A string in programming is just a fragment of text. To create the complete text label, we join the string “Player 10: ” to the name variable, e.g. “Player 10: Matt”.
● A website event triggers code execution. When a click event occurs, the code to update the label runs. This is the example that detects when the button has been clicked.
Programmers can use a programming API to create programs that are difficult to code or otherwise impossible. Programming kits are similar to ready-made furniture sets for home construction.
It is easier to build a bookcase if you use pre-assembled panels.
They can generally be broken down into two categories.
To expose computer data or perform complicated tasks, APIs are embedded in your web browser. Take, for example:
● The Document Object Model API (DOM) allows you to add, delete, edit, modify, or remove HTML. You can also apply dynamic styling to your pages using HTML and CSS. It’s the DOM that displays new content (as we saw in our example above) whenever you see a popup window appear on a page.
● The Geolocation API can retrieve geographic information. This API plots your exact location in Google Maps.
● Canvas and WebGL can be used to create 2D and 3-D animated graphics. See Chrome Experiments and webglsamples for some amazing examples of what’s possible using these web technologies.
● APIs such as HTMLMediaElement or WebRTC allow multimedia to be embedded within web pages. This allows you to make interesting multimedia projects on the internet. You can display a snapshot taken by your camera on someone else’s computer (see our simple Snapshot demo for more information).
Third-party APIs are not included in the default browser. You will need to download them from the Web. Examples include:
● Twitter API allows you to show tweets directly from your site.
● OpenStreetMap and Google Maps API provide different capabilities to embed custom maps in your site.