- Browser Application Programming Interfaces (APIs) built into web browsers, providing functionality such as dynamically creating HTML and setting CSS styles; collecting and manipulating a video stream from a user’s webcam, or generating 3D graphics and audio samples.
- Third-party APIs that allow developers to incorporate functionality in sites from other content providers, such as Twitter or Facebook.
- Third-party frameworks and libraries that you can apply to HTML to accelerate the work of building sites and applications.
The section below introduces some aspects of the core language and offers an opportunity to play with a few browser API features too. Have fun!
A Hello world! example
- Go to your test site and create a new folder named scripts. Within the scripts folder, create a new file called main.js, and save it.
- In your index.html file, enter this code on a new line, just before the closing </body> tag:
4. Add this code to the main.js file
const myHeading = document.querySelector(‘h1’);myHeading.textContent = ‘Hello world!
Following that, the code set the value of the myHeading variable’s textContent property (which represents the content of the heading) to Hello world!.
Note: Both of the features you used in this exercise are parts of the Document Object Model (DOM) API, which has the capability to manipulate documents.