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

Java Script

JavaScript is a case-sensitive scripting language primarily used for web development, enabling interactivity on websites. Key concepts include variables (var, let, const), data types (primitive and objects), operators, conditional statements, loops, functions, and DOM manipulation. The document also covers event handling, input/output methods, debugging, and provides exam-focused examples and a checklist.

Uploaded by

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

Java Script

JavaScript is a case-sensitive scripting language primarily used for web development, enabling interactivity on websites. Key concepts include variables (var, let, const), data types (primitive and objects), operators, conditional statements, loops, functions, and DOM manipulation. The document also covers event handling, input/output methods, debugging, and provides exam-focused examples and a checklist.

Uploaded by

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

🔑 JavaScript Essentials (Detailed Notes)

1. Introduction

 JavaScript is a scripting language mainly used for web development.


 Runs in the browser to make websites interactive (e.g., buttons, forms, animations).
 It is case-sensitive.

2. Variables

 Used to store data.


 Declared using:
o var → old way, function-scoped.
o let → modern, block-scoped.
o const → constant, cannot be reassigned.
 Example:

js
let name = "Khadija";
const pi = 3.14;

3. Data Types

 Primitive types: string, number, boolean, null, undefined.


 Objects: arrays, functions, custom objects.
 Example:

js
let age = 17; // number
let student = true; // boolean
let fruits = ["Apple", "Banana"]; // array

4. Operators

 Arithmetic: + - * / %
 Comparison: == === != !== > < >= <=
 Logical: && || !
 Assignment: = += -= *= /=

5. Conditional Statements

 Used for decision-making.

js
if (marks >= 90) {
[Link]("Grade A");
} else if (marks >= 70) {
[Link]("Grade B");
} else {
[Link]("Fail");
}

6. Loops

 for loop → repeat fixed times.


 while loop → repeat until condition false.
 do...while → runs at least once.

js
for (let i = 1; i <= 5; i++) {
[Link](i);
}

7. Functions

 Block of code that performs a task.

js
function greet(name) {
return "Hello " + name;
}
[Link](greet("Khadija"));

8. Events

 JavaScript reacts to user actions (click, hover, input).

html
<button onclick="alert('Hello!')">Click Me</button>

9. Arrays

 Store multiple values in one variable.

js
let colors = ["Red", "Green", "Blue"];
[Link](colors[0]); // Red

10. Objects

 Store data in key-value pairs.

js
let student = {
name: "Khadija",
age: 17,
grade: "A"
};
[Link]([Link]);

11. DOM Manipulation

 JavaScript can change HTML content.

js
[Link]("demo").innerHTML = "Hello World!";

12. Input & Output

 alert("Message") → popup box.


 [Link]("Message") → output in console.
 prompt("Enter name") → input from user.

13. Errors & Debugging

 Common mistakes: missing semicolon, wrong variable name, mismatched quotes.


 Use [Link]() to debug.

14. Important Exam Examples

 Hello World alert box:

js
alert("Hello, World!");

 Calculate Grade function:

js
function CalculateGrade(marks) {
if (marks >= 90) return "A";
else if (marks >= 70) return "B";
else if (marks >= 50) return "C";
else return "F";
}

 JavaScript addition vs subtraction:

js
let a = 10;
let b = "5";
[Link](a + b); // "105" (string concatenation)
[Link](a - b); // 5 (number subtraction)
🎯 Exam-Focused Checklist
 ✅ Keywords: var, let, const
 ✅ Alert box syntax
 ✅ Difference between == and ===
 ✅ Arrays & Objects basics
 ✅ Event handling (onclick)
 ✅ Simple function for grading
 ✅ JavaScript data type quirks (string + number)

You might also like