0% found this document useful (0 votes)
5 views5 pages

Java Script

JavaScript is a high-level, interpreted programming language used for creating interactive and dynamic web pages. It features client-side execution, dynamic typing, and can be utilized for both frontend and backend development. JavaScript supports various data types and is essential for web development, enabling tasks such as DOM manipulation, form validation, and asynchronous data fetching.

Uploaded by

mathegirish
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views5 pages

Java Script

JavaScript is a high-level, interpreted programming language used for creating interactive and dynamic web pages. It features client-side execution, dynamic typing, and can be utilized for both frontend and backend development. JavaScript supports various data types and is essential for web development, enabling tasks such as DOM manipulation, form validation, and asynchronous data fetching.

Uploaded by

mathegirish
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

JAVA SCRIPT

What is JavaScript?

JavaScript (often abbreviated as JS) is a high-level, interpreted programming


language primarily used to make web pages interactive and dynamic.
It runs directly in the browser without the need for compilation, and is supported by all
modern web browsers.

Key Features

• Client-Side Execution: Runs in the user's browser, reducing server load.


• Dynamic Typing: No need to declare variable types explicitly.
• Event-Driven: Responds to user actions like clicks, key presses, and mouse
movements.
• Cross-Platform: Works on all major operating systems and browsers.
• Versatile: Can be used for frontend (with HTML/CSS) and backend (with [Link]).

What Can JavaScript Do?

• Change HTML content and styles dynamically.


• Validate form inputs before sending data to the server.
• Create animations and interactive effects.
• Fetch and send data asynchronously (AJAX / Fetch API).
• Build full-stack applications (with [Link], Express, MongoDB, etc.).

Basic Example

Here’s a simple JavaScript example that changes text when a button is clicked:

Html
Copy code
<!DOCTYPE html>
<html>
<head>
<title>JavaScript Example</title>
</head>
<body>
<h1 id="demo">Hello, World!</h1>
<button onclick="changeText()">Click Me</button>

<script>
// Function to change the text content
function changeText() {
[Link]("demo").innerText = "JavaScript is
awesome!";
}
</script>
</body>
</html>

How it works:

1. HTML displays a heading and a button.


2. When the button is clicked, the changeText() function runs.
3. JavaScript changes the text inside the <h1> tag.

Why Learn JavaScript?

• It’s the most popular programming language for web development.


• Essential for frontend development and widely used in backend.
• Huge community support and vast libraries/frameworks (React, Angular, Vue, etc.).
• High demand in the job market.

If you want, I can prepare a step-by-step JavaScript learning roadmap with examples so you
can go from beginner to advanced quickly.
Do you want me to prepare that?

JavaScript is a versatile and widely-used programming language primarily known for its role
in web development. It allows developers to create dynamic and interactive web pages by
manipulating HTML and CSS. JavaScript can also perform calculations, validate data, and
handle various events.

Key Features of JavaScript

• Manipulating HTML Content: JavaScript can change the content of HTML elements
using methods like getElementById(). For example:
[Link]("demo").innerHTML = "Hello JavaScript";

• Changing HTML Attributes: JavaScript can modify the attributes of HTML elements.
For instance, changing the src attribute of an <img> tag:
[Link]("myImage").src = "[Link]";

• Modifying CSS Styles: JavaScript can alter the styles of HTML elements, such as
changing the font size:
[Link]("demo").[Link] = "35px";

• Hiding and Showing Elements: JavaScript can hide or show HTML elements by
changing their display style:
[Link]("demo").[Link] = "none"; // Hide
[Link]("demo").[Link] = "block"; // Show

JavaScript Data Types

JavaScript supports various data types, including:


• Numbers: JavaScript has a single type for numbers, which can be written with or
without decimals.
var x = 3.14; // A number with decimals
var y = 3; // A number without decimals

• Strings: Strings are used to store text and can be enclosed in single or double
quotes.
var carName = "Volvo"; // Double quotes
var carName = 'Volvo'; // Single quotes

• Objects: Objects are variables that can hold multiple values in key-value pairs.
var car = {type:"Fiat", model:"500", color:"white"};

• Arrays: Arrays are used to store multiple values in a single variable.


var cars = ["Saab", "Volvo", "BMW"];

• Functions: Functions are blocks of code designed to perform specific tasks and are
executed when called.
function myFunction(p1, p2) {
return p1 * p2; // Returns the product of p1 and p2
}
Practical Applications

JavaScript is essential for web development and is one of the three core technologies
alongside HTML and CSS. It enables developers to create interactive and dynamic web
pages, enhancing user experience. JavaScript can also be used for server-side development
with environments like [Link].
TYPES OF SCRIPTING

A client-side scripting language is a programming language used to create scripts that run
directly in the user's web browser, rather than on a web server. These scripts are embedded
within HTML or stored in external files and are executed by the browser to enhance the
interactivity and responsiveness of web pages.
Client-side scripting is primarily used for tasks such as form validation, dynamic content
updates, animations, and user interface enhancements. It reduces the load on the server by
processing data locally on the user's device.
A server-side script is a program that is executed on the server side when the user requests
information. The script do not download at the client side.
When the client or visitor requests the page, the web server reads it first. After reading, the
web server locates the page file on the disk, loads into memory and asks the script engines
(or interpreter) to process the script code.

While Loops

While loops execute a block of code as long as a specified condition is true.

JavaScript have two types of while loops:

• The while loop


• The do while loop

The While Loop

The while loop loops through a block of code as long as a specified condition is true.

Syntax
while (condition) {
// code block to be executed
}

In the following example, the code in the loop will run, over and over again, as long as a
variable (i) is less than 10:

Example
while (i < 10) {
text += "The number is " + i;
i++;
}
Try it Yourself »

Note

If you forget to increase the variable used in the condition, the loop will never end.

This will crash your browser.

The Do While Loop

The do while loop is a variant of the while loop. This loop will execute the code block once,
before checking if the condition is true, then it will repeat the loop as long as the condition is
true.

Syntax
do {
// code block to be executed
}
while (condition);

Note

The do while runs at least once, even if the condition is false from the start.

This is because the code block is executed before the condition is tested:

Example
do {
text += "The number is " + i;
i++;
}
while (i < 10);

You might also like