JavaScript Basics
JavaScript Basics
1. Introduction
JavaScript is a scripting language that adds interactivity to web pages. It is used for dynamic
behavior like form validation, animations, and event handling.
2. JavaScript Syntax
JavaScript can be written inside an HTML file using the <script> tag:
<script>
alert('Hello, JavaScript!');
</script>
- Declaring variables:
const PI = 3.14;
- Functions:
function greet() {
alert('Welcome to JavaScript!');
<!DOCTYPE html>
<html>
<head>
<title>JavaScript Example</title>
</head>
<body>
<script>
function showMessage() {
</script>
</body>
</html>