0% found this document useful (0 votes)
10 views

Typescript Class Notes Part 2

Uploaded by

moriishikaa
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Typescript Class Notes Part 2

Uploaded by

moriishikaa
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

JavaScript Class Notes

Introduction to JavaScript

• Definition: JavaScript is a high-level, interpreted programming language that enables


dynamic interaction on websites.

• Key Features:

o Lightweight and versatile.

o Supports object-oriented, functional, and imperative programming styles.

o Runs on the client-side (browser) but also on the server-side (Node.js).

Core Concepts

1. Variables: Containers for storing data values.

o Declaration: var, let, const.

o Example:

javascript

Copy code

let name = "Alice";

const age = 25;

var isStudent = true;

2. Data Types:

o Primitive: Number, String, Boolean, Undefined, Null, Symbol, BigInt.

o Non-Primitive: Objects (Arrays, Functions, etc.).

o Example:

javascript

Copy code

let number = 10; // Number

let message = "Hello"; // String

let isReady = false; // Boolean

3. Operators:

o Arithmetic: +, -, *, /, %.

o Comparison: ==, ===, !=, !==, <, >, <=, >=.


o Logical: &&, ||, !.

4. Functions: Blocks of reusable code.

o Declaration:

javascript

Copy code

function greet(name) {

return `Hello, ${name}!`;

o Arrow Function:

javascript

Copy code

const greet = (name) => `Hello, ${name}!`;

5. Control Structures:

o Conditional Statements: if, else, else if, switch.

o Loops: for, while, do...while, for...in, for...of.

o Example:

javascript

Copy code

for (let i = 0; i < 5; i++) {

console.log(i);

DOM Manipulation

• Access and modify HTML elements using JavaScript.

• Common Methods:

o document.getElementById("id")

o document.querySelector("selector")

o element.textContent or element.innerHTML

Events

• JavaScript can react to user actions like clicks, typing, or loading.


• Example:

javascript

Copy code

document.querySelector("button").addEventListener("click", () => {

alert("Button clicked!");

});

Key Takeaways

• JavaScript adds interactivity and dynamic functionality to websites.

• It integrates seamlessly with HTML and CSS.

• Practice is essential for mastering its syntax and features.

New part of the first one

You might also like