0% found this document useful (0 votes)
2 views2 pages

JavaScript Basics for Beginners

This document is a beginner tutorial on JavaScript, covering its definition, variables, data types, operators, conditions, loops, functions, arrays, objects, and how to manipulate the DOM. It provides examples for each concept to illustrate their usage. The tutorial serves as an introductory guide for those new to JavaScript programming.

Uploaded by

Safvannk Manjeri
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)
2 views2 pages

JavaScript Basics for Beginners

This document is a beginner tutorial on JavaScript, covering its definition, variables, data types, operators, conditions, loops, functions, arrays, objects, and how to manipulate the DOM. It provides examples for each concept to illustrate their usage. The tutorial serves as an introductory guide for those new to JavaScript programming.

Uploaded by

Safvannk Manjeri
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

JavaScript Beginner Tutorial

1. What is JavaScript?
JavaScript is a programming language that makes websites interactive. Example: when you click a
button and something happens.

2. Variables (Storing Data)


We use variables to store values. Example:
let name = 'John'; let age = 20; let isStudent = true;

3. Data Types
Main types:
- String → 'Hello'
- Number → 10, 3.14
- Boolean → true, false
- Array → ['Apple','Banana']
- Object → {name:'Ali', age:25}

4. Operators
Common operators:
+ Add, - Subtract, * Multiply, / Divide, % Remainder

5. Conditions (if / else)


Conditions allow decision-making. Example:
if (age >= 18) { [Link]('Adult'); } else { [Link]('Minor'); }

6. Loops (Repeat Actions)


For loop example:
for (let i=1; i<=5; i++){ [Link](i); }
While loop example:
let i=1; while(i<=3){ [Link](i); i++; }

7. Functions
Functions allow reusing code. Example:
function greet(name){ [Link]('Hello '+name); }

8. Arrays
Arrays store multiple values. Example:
let colors=['Red','Green','Blue']; [Link]('Yellow');
9. Objects
Objects store key-value pairs. Example:
let person={name:'Ayesha', age:22}; [Link]([Link]);

10. DOM (Change HTML with JavaScript)


JavaScript can change webpage content. Example:
[Link]('title').innerHTML='New Text!';

Summary
✔ Variables
✔ Data Types
✔ Operators
✔ Conditions
✔ Loops
✔ Functions
✔ Arrays & Objects
✔ DOM basics

You might also like