Basics
What is JavaScript?
The programming language of the web — runs in browsers and on servers.
1. Explanation
JavaScript is a high-level, interpreted programming language created by Brendan Eich in 1995. It runs natively in every web browser and on servers via Node.js. JavaScript adds interactivity to web pages — handling clicks, validating forms, fetching data, animating elements and building full applications. Together with HTML (structure) and CSS (style), JavaScript (behavior) makes up the foundation of the modern web.
2. Syntax
js
<script>
// your JavaScript here
</script>3. Example
Try it yourself
Console
Click Run to see output.
4. Expected output
output
Hello, JavaScript!5. Common mistakes
- ✗Forgetting to link the .js file with <script src="app.js"></script>
- ✗Placing the <script> tag in <head> without 'defer', causing it to run before the DOM exists
- ✗Confusing JavaScript with Java — they are completely different languages
6. Practice questions
- Create an HTML file that loads a script and logs your name to the console
- Use console.log to print the result of 5 + 7
- Change document.title to your favorite quote
7. Mini project
Hello User
Prompt the user for their name and greet them.
js
const name = prompt("What's your name?");
alert("Hello, " + name + "!");