Welcome to the JavaScript Basics Repository! This repository is designed to help you learn JavaScript from the ground up, with clear, executable code examples demonstrating core concepts and best practices.
To start working with this repository without affecting the original codebase, we recommend forking it, and then cloning your fork.
Click the Fork button at the top right of this page. This creates a copy of the repository in your own GitHub account.
Clone the forked repository to your local machine. Open your terminal and run:
git clone https://github.com/YOUR_USERNAME/JavaScriptBasics-.git(Replace YOUR_USERNAME with your actual GitHub username)
Navigate into the directory and install the necessary dependencies (for linting and formatting):
cd JavaScriptBasics-
npm installThe repository is organized into modules covering various JavaScript topics:
01-variables-and-data-types/:let,const, primitive and reference types.02-control-flow/: Conditionals and loops.03-functions/: Scopes, closures, arrow functions.04-arrays-and-objects/: Iteration, destructuring, spread syntax.05-classes-and-prototypes/: Object-oriented programming in JS.06-async-javascript/: Promises, async/await.07-error-handling/: Handling exceptions gracefully.08-modules/: Code split and organization.09-hoisting/: Function hoisting, variable hoisting, and the Temporal Dead Zone (TDZ).10-real-world-scenarios/: Practical, everyday programming challenges including form validation, shopping cart computing, data filtering, and DOM updates.git-and-github-basics/: Beginner-friendly guides to version control, covering Git installation, local workflows (add/commit), GitHub collaboration (push/pull), and branching routines with visual diagrams.
Each module contains JavaScript files that you can run directly using Node.js to see the output.
For example, to run the variables example:
node 01-variables-and-data-types/index.jsWe recommend reading the comments in the code and observing the console output to understand what is happening.
Throughout the codebase, you will see a custom logging utility imported from utils/logger.js. While it may look like an installed npm package, it is actually a local module built specifically for this repository.
Its main benefits in this codebase include:
- Visual Clarity: Formats console output with colors and clear boundaries, making it easier to distinguish different concepts and steps in the terminal.
- Categorization: Provides specific methods (
logger.section(),logger.step(),logger.info(),logger.warn()) to logically group and highlight important information or common pitfalls. - Improved Learning Experience: Separates the structured demonstration output from standard
console.logcalls, significantly improving the reading experience when you run the examples.
This project enforces modern JavaScript best practices (ES6+) using ESLint and Prettier.
- Check code quality:
npm run lint - Format code:
npm run format