Overview
This course teaches JavaScript from beginner to professional, focusing on building interactive websites like Amazon.com. Key concepts include JavaScript basics, DOM manipulation, HTML/CSS integration, advanced features like OOP, asynchronous programming, and backend communication.
Course Structure & Projects
- The course progresses from JavaScript basics to advanced topics step by step.
- Major projects include an Amazon.com clone and smaller apps (rock-paper-scissors, to-do list, calculator).
- Each lesson features exercises for practice, with over 250 in total.
JavaScript Fundamentals
- JavaScript makes websites interactive by responding to user actions.
- Code is a set of instructions; running code executes these instructions.
- Syntax rules must be followed exactly for code to work.
- JavaScript can perform calculations, manipulate webpage content, and create popups.
Working with Numbers & Math
- JavaScript supports addition (+), subtraction (-), multiplication (*), division (/).
- Order of operations: brackets > multiplication/division > addition/subtraction.
- Calculations with decimal numbers (floats) can be inaccurate; use cents for money calculations.
- Rounding numbers:
Math.round() rounds to the nearest integer.*
Working with Strings (Text)
- Strings are pieces of text surrounded by quotes (' or ").
- Strings can be concatenated (combined) using the + operator.
- Template strings (backticks ``) allow embedding values with
${}.
- Escape characters like
\', \", and \n are used for special characters and new lines.
HTML, CSS, & JavaScript Together
- HTML creates content; CSS styles it; JavaScript adds interactivity.
- Use Visual Studio Code as a code editor, and Google Chrome as a browser.
- JavaScript runs inside
<script> tags or through attributes like onclick.
- Comments (// or /* */) clarify code or temporarily disable lines.
console.log() outputs results to the browser console for debugging.
Variables
- Variables store values (numbers, strings, objects).
- Declare variables with
let, const (cannot be reassigned), or var (not recommended).
- Use camelCase for variable names.
- Reassign values by writing
variableName = newValue;.
Booleans & If Statements
- Booleans have two values:
true and false.
- Comparisons use operators like
>, <, >=, <=, ===, !==.
if, else if, else control which code runs based on conditions.
- Logical operators:
&& (and), || (or), ! (not).
- Truthy/falsy values:
0, '', null, undefined, NaN are falsy; all else is truthy.
Functions
- Functions group reusable code blocks; define with
function name() {}.
- Functions can take parameters (inputs) and return values (outputs).
- Functions help organize code and reduce repetition.
Objects & Arrays
- Objects group related values using properties (key-value pairs).
- Arrays store ordered lists of values; access items by index (starting at 0).
- Use dot notation (
obj.property) or bracket notation (obj['property']).
- Common array methods:
.push(), .splice(), .forEach(), .map(), .filter().
DOM Manipulation
- The Document Object Model (DOM) lets JavaScript access and modify HTML elements.
- Use
document.querySelector to get elements and .innerHTML to change them.
- Add event listeners (e.g.,
element.addEventListener('click', function)) for interactivity.
- Classes and IDs help target specific elements for styling and scripting.
Asynchronous JavaScript
- Asynchronous code runs in the background, e.g., fetching data from a server.
- Callbacks, promises, and async/await handle asynchronous operations.
- Promises use
.then() and .catch(); async functions use await to pause until a promise resolves.
Backend Concepts
- The backend is a separate computer/server that stores and manages data.
- Communication uses HTTP requests (GET, POST, etc.) via URLs (APIs).
- Fetch API is used to send requests and handle responses in JavaScript.
Testing & Debugging
- Manual testing: try features directly in the browser.
- Automated testing: write code to test code (unit/integration tests).
- Testing frameworks (e.g., Jasmine) help organize and run tests.
- Use
describe for test suites, it for tests, and expect for assertions.
Object-Oriented Programming (OOP)
- OOP organizes code into objects and classes.
- Classes are blueprints for creating objects and can inherit from each other.
- Use
constructor for initialization, and methods for actions.
- Private properties and methods (prefix with
#) restrict access outside the class.
- Concepts: inheritance, method overriding, polymorphism, MVC (Model-View-Controller).
Key Terms & Definitions
- Syntax — Rules for writing code; must be followed for code to work.
- Variable — A container for storing values.
- Boolean — A value of
true or false.
- Array — An ordered list of values, accessed by index.
- Object — A group of key-value pairs (properties and methods).
- Function — A reusable set of instructions.
- Callback — A function passed as an argument to be run later.
- Promise — An object representing a future value.
- Async/Await — Syntax for handling promises in a readable way.
- DOM — The Document Object Model, representing the web page structure.
- Class — An OOP blueprint for creating objects.
- Inheritance — Mechanism by which a class derives properties/methods from another.
- Event Listener — Code that reacts to user actions like clicks or key presses.
Action Items / Next Steps
- Complete coding exercises provided after each lesson.
- Build and style the Amazon, rock-paper-scissors, to-do list, and calculator projects.
- Practice using testing frameworks and debugging tools.
- Explore backend concepts, APIs, and asynchronous code with fetch.
- Continue learning Node.js and backend development for full-stack skills.