JavaScript Full Course. Let’s Master javaScript practically.
Module 1 Introduction to JavaScript and Computer Programming; Module 2 Variables, Data Types, Type Casting, and Comments; Module 3 Operators and User Interaction; Module 4 Control Flow – Conditional Execution and Loops; Module 5 Functions; Module 6 Errors, exceptions, debugging, and troubleshooting..
Introduction to JavaScript How JS communicates with the computer What is JavaScript? Advantages & Limitations Where JS is used today Setting up Environment Browser Code editor (VS Code) Node.js (optional) First Program – Hello, World!.
Found in phones, TVs, medical tools, banking, business Computers are fast & accurate but need instructions We communicate through programming languages.
Computers understand only low-level machine code (numbers) Humans can’t easily read this Solution: Programming languages → closer to natural language, easier for humans.
Natural Languages Humans use natural languages (English, Amharic, etc.) Computers cannot understand them directly Machine Language Computers understand only 0s and 1s (binary code)Example: 00000000 for 0, 00000001 for 1, 00000010 for 2, 00000011 for 3 10110100 11001010 Too hard for humans to read or write Assembly Language First step to make coding easier Uses mnemonics instead of 0s and 1s. Example: MOV AX, 01 Still low-level and hardware-specific Uses symbolic instructions (MOV, ADD, SUB) mapped to machine code. Each CPU (Intel, ARM, MIPS, RISC-V) has its own ISA. Assembly for one CPU won’t run on another..
High-Level Languages Closer to human thinking, Examples: FORTRAN, COBOL, C Translated into machine code by compiler/interpreter High-level languages (like Python, Java, C++) are not device specific, because compilers and interpreters handle translation into the target machine code. Specialized Languages Different tasks need different languages C → system programming SQL → databases HTML (1991) → web pages (but static, no interactivity) The Web Problem (1990s) Early web pages = only text, images, links No interactivity (couldn’t validate forms or react to users) A lightweight browser-based scripting language was neededBirth of JavaScript (1995).
Created by Brendan Eich at Netscape Purpose: make web pages interactive Example: form validation before sending data to server Why JavaScript Was Needed Bridge between human language → programming language → machine code Specifically designed for the web Easy, flexible, and runs directly in browsers Impact of JavaScript Turned the web from static → dynamic & interactive Foundation for modern web apps Natural Language (humans) → Machine Language (computers) → High-Level Languages → JavaScript (for the web).
JavaScript = interpreted, high-level language Runs in browsers via built-in JS engines Can also run outside browsers via Node.js Uses JIT Compilation for faster execution.
First: clearly define the problem Then: design the solution Finally: write code with unambiguous instructions Example: furniture assembly needs clear, step-by-step instructions.
1995: Created by Brendan Eich at Netscape First named LiveScript, soon changed to JavaScript Goal: make websites dynamic & interactive.
Client-side: runs in browser, adds interactivity (e.g. forms, games, dynamic pages) Server-side: runs on servers (via Node.js), handles data, backend logic Today: Used in web apps, mobile apps, even drones.
Not perfect for high-performance or heavy math apps Browser sandbox limits access to local files Source code is visible → risk of copying/stealing Workarounds: code obfuscation, but still limited.
Huge community support & active tools Many frameworks (React, Angular, etc.) Easy to learn & supported by all major browsers Free tools → already inside your browser Flexible syntax, good for beginners Led to TypeScript (adds static typing).
Environments: Browser or Node.js Core language concepts: variables, functions, loops, conditions Learning = practice → write lots of code Stay patient, take breaks, keep coding Let’s begin the adventure! 🚀.
Why Tools Matter Programming requires the right tools (like any job) Minimum: Code Editor + Interpreter Works on any OS (Windows, macOS, Linux) Working Environments Two main options: Online environment -, quick & easy but limited Local environment – install tools on your computer (preferred in real projects).
Online Development Environments “Code playgrounds” = editor + runtime in browser Features: write, run, share code Good for testing, training, publishing small solutions, like CodePen Local Development Environment Best for real-world projects Minimal trio needed:Code Editor, Interpreter and Debugger Code Editor Basics, Code = plain text → requires a plain text editor Word processors (like MS Word) don’t work Benefits of code editors:Syntax highlighting, Autocomplete and Error checking.
1. Inline JavaScript 👉 Best for very small scripts. You write JavaScript directly inside an HTML tag using the onclick, onchange, or other event attributes. <!DOCTYPE html> <html> <head> <title>Inline JS Example</title> </head> <body> <button onclick="alert('Hello from Inline JS!')">Click Me</button> </body> </html>.
2. Internal JavaScript 👉 Best for small projects or demos. write JavaScript inside the <script> tag within the same HTML file. <!DOCTYPE html> <html> <head> <title>Internal JS Example</title> <script> function showMessage() </script> </head> <body> <button onclick="showMessage()">Click Me</button> </body> </html>.
3. External JavaScript 👉 Best practice for large and projects. write JavaScript in a separate .js file and link it using <script src="...">. <!-- index.html --> <!DOCTYPE html> <html> <head> <title>External JS Example</title> <script src="script.js"></script> </head> <body> <button onclick="showMessage()">Click Me</button> </body> </html>.
3. External JavaScript // script.js function showMessage().
Thank you for watching Like comment and subscribe Join my telegram channel to get this teaching pdf materials: Next Course: Module 2 Variables, Data Types, Type Casting, and Comments; https://t.me/codesweb23 ..
Module 2 Variables, Data Types, Type Casting, and Comments;.
Text ignored by the interpreter. Make code easier to read, explain, and maintain. Useful for teams & for revisiting old code. Two Types of Comments Single-line → // comment let x = 42; // single-line comment Multi-line (block) → /* ... */ /* this is a block comment */.
Programs need to store and reuse values → not just print text. Variables = containers that hold data for later use. They let us: Save intermediate results. Reuse values in later operations. Modify and update information dynamically..
Good names describe content: height, stepCounter, color. Rules in JavaScript: Can use letters, digits, _, $. Cannot start with a digit. Case-sensitive: test, Test, TEST = different. Avoid reserved words (if, for, let, etc.). Declare before use → let height;.
Keywords: let → declare a variable (recommended). var → old style, allows redeclaration (error-prone). const → declare constants (values that never change). let height; console.log(height); // undefined let prevents accidental redeclaration..
Initialization = first assignment → use = operator.let steps = 100; steps = steps + 50; // 150 Variables can hold different types: Numbers → let age = 25; Strings → let name = "Alice"; JavaScript is dynamically typed → a variable can change type.let greeting = "Hello!"; greeting = 1; // allowed.
Constants → values that cannot change. const pi = 3.14; pi = 3.14159; // Error Use for fixed values (tokens, paths, settings). "use strict"; → enforces modern JS rules: Prevents using undeclared variables. Safer, more predictable code..
Global → declared outside blocks, visible everywhere. Local → declared inside blocks {} or functions. let x = 10; // global let & const → block scope. var → ignores blocks, only scoped inside functions. ⚠️ Avoid shadowing (using same name inside/outside)..
Hoisting: declarations are moved to the top by JS engine. With var: declared but not initialized → undefined. With let & const: safer, less confusing. Best Practices: Always declare before use. Prefer let & const over var. Use clear, descriptive names. Don’t redeclare or shadow variables. Keep constants for values that never change..
Why Data Types? Programs process different kinds of data: numbers, text, flags, etc. Data types decide: What values can be stored. What operations are allowed. JavaScript is weakly typed → variables can change type. Literals = fixed values written directly in code. let year = 1990; // number literal console.log("Alice"); // string literal Each type has its own literal form..
typeof Operator Returns the data type of a value/variable.let name = "Alice"; console.log(typeof name); // "string" console.log(typeof 1991); // "number" Possible results: "undefined", "object", "boolean", "number", "bigint", "string", "symbol", "function".
Primitive Types 7 Primitives + null: boolean, number, bigint, string, symbol, undefined, null. Primitive = atomic value (cannot be broken down). Boolean → true / false (used in conditions). Number → integers + fractions, supports arithmetic. let isGameOver = false; let year = 1991; Special numbers: Infinity, -Infinity, NaN..
BigInt → very large integers (123n). let big = 1234567890123456789n; String → text inside quotes ("Hello" or 'Hi'). Operations: concatenation +, interpolation `Hello $`. Undefined → default for uninitialized vars. Null → intentional "no value". Symbol → unique identifiers (advanced, rare). let x; console.log(x); // undefined let y = null;.
Conversions (Explicit) Constructor functions: String(), Number(), Boolean(), BigInt(). String(42); // "42" Number("11"); // 11 Boolean(0); // false BigInt("99"); // 99n.
Conversion Rules To String → everything becomes readable text. To Number → works if value looks numeric; else NaN. To Boolean → false for 0, NaN, "", undefined, null. → true for everything else. To BigInt → needs integer or numeric string; errors otherwise. Implicit Conversion Happens automatically in operations. 42 + "1" // "421" (string) 42 - "1" // 41 (number) ⚠️ Be careful → may cause unexpected results!.
Objects: store related data with names (properties). Objects = key–value pairs (properties). Store multiple related values in one place.let user =; console.log(user.name); // Calvin Can read, update, add, or delete properties: user.age = 67; user.phone = "123-456"; delete user.phone;.
Arrays Arrays = ordered collections, indexed from 0. Use square brackets to create and access elements. let days = ["Sun", "Mon", "Tue"]; console.log(days[0]); // Sun days[0] = "Sunday"; // update Can mix types: let values = ["Test", 7, false]; Arrays can be nested..
Useful Array Methods length → number of elements. indexOf(value) → position or -1. Add: push() (end), unshift() (start). Remove: pop() (end), shift() (start). reverse() → flips order. slice(start, end) → copy part of array. concat() → combine arrays. let names = ["Olivia", "Emma"]; names.push("Mateo"); // ["Olivia","Emma","Mateo"] Slide 5 – Key Takeaways Objects → Arrays → store ordered lists (by index). Arrays can hold different types & even objects. Arrays = objects in JS → typeof [] // "object". Many built-in methods make arrays flexible & powerful..
Useful Array Methods Arrays → store ordered lists (by index). Arrays can hold different types & even objects. Arrays = objects in JS → typeof [] // "object". Many built-in methods make arrays flexible & powerful..
Thank you for watching Like comment and subscribe Join my telegram channel to get this teaching pdf materials: Next Course: Module 2 Variables, Data Types, Type Casting, and Comments; https://t.me/codesweb23 ..
Assignment, Arithmetic & Logical Operators Operators Intro Operators → symbols that perform actions on values (operands). Types: Unary → 1 operand (typeof x) Binary → 2 operands (x + y) Ternary → 3 operands (cond ? a : b) Placement: prefix, postfix, infix..
Assignment Operator = assigns right operand to left operand. const name = "Alice"; console.log(name); // Alice Assignment Order Right-to-left execution. let year = 2050; let newYear = year = 2051; console.log(newYear); // 2051.
Arithmetic Operators + addition - subtraction * multiplication / division % remainder ** power const x = 5, y = 2; console.log(x + y); // 7 console.log(x ** y); // 25.
Operator Precedence Parentheses control order. console.log(2 + 2 * 2); // 6 console.log((2 + 2) * 2); // 8 Unary + and - Convert to Number. let str = "123"; console.log(+str); // 123 (number) console.log(-str); // -123.
Increment & Decrement ++ increase by 1, -- decrease by 1. Prefix vs Postfix. let n = 5; console.log(n++); // 5 (then n=6) console.log(++n); // 7 Floating Point Quirks Some results imprecise. console.log(0.2 + 0.1); // 0.3000000004.
Compound Assignment +=, -=, *=, /=, %=, **= let x = 10; x += 2; // 12x *= 3; // 36 Logical Operators && AND → true if both true || OR → true if at least one true ! NOT → reverses boolean console.log(true && false); // false console.log(!true); // false.
Non-Boolean Logic Works with other types too. console.log("Alice" && "Bob"); // Bob console.log("" || "Bob"); // Bob console.log(!!"Hi"); // true Compound Logical Assignment Combine with assignment. let a = true; a &&= false; // a = a && false → false let b = false; b ||= true; // b = b || true → true.
Thank you for watching Like comment and subscribe Join my telegram channel to get this teaching pdf materials: Next Course: Module 2 Variables, Data Types, Type Casting, and Comments; https://t.me/codesweb23 ..