JavaScript is a programming language that allows web pages to be more interactive and dynamic. To add JavaScript to a web page, code is placed between opening and closing <script> tags, which can be inside the <head> or <body> sections. JavaScript code can either be directly written in the HTML file between <script> tags, or it can be saved in an external .js file and linked using the src attribute of the <script> tag. A basic "Hello World" JavaScript program uses the document.write() function to output text directly onto the web page. External JavaScript files allow code to be shared across multiple pages and edited in one place.