0% found this document useful (0 votes)
29 views4 pages

Js 1

The document provides an introduction to JavaScript, highlighting its capabilities such as client-side scripting, dynamic content creation, and asynchronous programming. It covers basic syntax, including variables, data types, and functions, as well as interaction with the Document Object Model (DOM). Additionally, it mentions popular JavaScript frameworks and libraries like React, Vue, Angular, and jQuery that aid in development.
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)
29 views4 pages

Js 1

The document provides an introduction to JavaScript, highlighting its capabilities such as client-side scripting, dynamic content creation, and asynchronous programming. It covers basic syntax, including variables, data types, and functions, as well as interaction with the Document Object Model (DOM). Additionally, it mentions popular JavaScript frameworks and libraries like React, Vue, Angular, and jQuery that aid in development.
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
You are on page 1/ 4

INTRODUCTION TI JAVASCRIPT

1-What JavaScript Does

 Client-Side Scripting: JavaScript runs in the user's


browser, allowing websites to respond to user interactions
immediately without needing to reload the page.
 Dynamic Content Creation: JavaScript can add, remove,
and modify HTML and CSS on the fly, enabling dynamic
updates to web content.
 Asynchronous Programming: JavaScript enables
asynchronous operations (such as loading data in the
background) via callbacks, promises, and async/await
functions.
 Interactivity and Animation: JavaScript handles a
variety of animations, transitions, and interactivity, from
sliders and modals to complex visualizations.

2-Getting Started with JavaScript

 Embedding JavaScript: You can embed JavaScript in an


HTML file by using <script> tags

<!DOCTYPE html>

<html>

<head>

<title>My First JavaScript Page</title>

</head>

<body>

<h1>Hello, World!</h1>

<script>

document.write("Welcome to JavaScript!");
Console.log(“hello”);

</script>

</body>

</html>

External JavaScript File: JavaScript code can also be saved in


an external .js file and linked to an HTML file.

<script src="script.js"></script>

3. Basic JavaScript Syntax

 Variables: Variables are used to store data. You can


declare variables using var, let, or const.

let name = "Alice";

const age = 25;

· Data Types: JavaScript supports various data types, including


strings, numbers, booleans, arrays, and objects.
· Operators: JavaScript includes operators for arithmetic (+, -,
*, /), comparison (==, !=, ===, !==), and logical operations (&&,
||, !).

4. JavaScript Fundamentals

 Functions: Functions are reusable blocks of code that


perform a specific task

function greet() {
console.log("Hello, World!");

greet();

Events: JavaScript can react to user interactions (like clicks,


hovers, and form submissions) using event listeners.

document.getElementById("myButton").addEventListener("clic
k", function() {

alert("Button clicked!");

});

Control Structures: JavaScript includes conditionals (if, else,


switch) and loops (for, while) to control code flow.

5. JavaScript and the Document Object Model (DOM)

JavaScript interacts with the DOM, which represents the


structure of an HTML document. Using JavaScript, you
can select, modify, and manipulate HTML elements in
real-time.

document.getElementById("myElement").innerHTML =
"Updated Content";

6. Popular JavaScript Frameworks and Libraries

 JavaScript has many frameworks and libraries that


simplify development, including:
o React (for UI components)
o Vue (for single-page applications)
o Angular (for large-scale applications)
o jQuery (for simplifying DOM manipulation)

You might also like