Web Technologies Unit-2
Introduction to JavaScript
What is JavaScript?
JavaScript is a lightweight, interpreted programming language.
It is mainly used to create interactive and dynamic content on websites.
JavaScript is client-side, meaning it runs on the user's browser.
It is one of the core technologies of the web: HTML, CSS, and JavaScript.
Features of JavaScript
1. Dynamic – Allows dynamic content updates without page reloads.
2. Interpreted – Code is executed line-by-line by the browser.
3. Event-driven – Reacts to user actions (like clicks, mouse movement).
4. Object-based – Supports objects similar to OOP languages.
5. Platform-independent – Runs on any browser (Chrome, Firefox, etc.).
Why Use JavaScript?
To validate forms (like checking if an email is entered correctly).
To create animations and interactive effects.
To respond to user inputs (like button clicks).
To communicate with servers using AJAX for dynamic content.
Where is JavaScript Used?
1. Web Development – Adding logic and interactivity.
2. Game Development – Browser-based games.
3. Mobile App Development – Using frameworks like React Native.
4. Server-side Development – Using [Link].
5. Web APIs – Accessing browser features like geolocation, local storage.
Basic Syntax Example
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Example</h2>
<p id="demo">Click the button to change this text.</p>
<button Me!</button>
<script>
function changeText() {
[Link]("demo").innerHTML = "Hello, JavaScript!";
}
</script>
</body>
</html>
Department of CSM AITAM, TEKKALI