Live Demo: — | Issues: GitHub Issues | Pull Requests: GitHub PRs
Js is a curated collection of bite‑size JavaScript snippets that illustrate core language concepts—from variables and data types to advanced topics like prototypes, classes, and symbols. It is designed for:
- Beginners who want to see each concept in isolation.
- Instructors looking for ready‑made examples for workshops or cohort sessions.
- Anyone who needs a quick reference while learning or teaching JavaScript.
All examples are runnable with Node.js (no external dependencies) and are organized into logical folders like BackToBasic.js, Cohort, and Namaste JavaScript for easy navigation.
| Category | Files | Description | Status |
|---|---|---|---|
| Basics | JavaScript/test.js, BackToBasic.js/hello.js, Cohort/01-console.js, Namaste JavaScript/index.js |
Simple console output, environment tests, and basic function definitions. | ✅ Stable |
| Variables & Types | BackToBasic.js/01_Varialble.js, 02_datatypes.js, datatypes_symry.js, JavaScript/01_Variables.js, 02_DataTypes.js |
Declaration, scope, strict mode, and primitive vs reference types. | ✅ Stable |
| Conversions & Operations | BackToBasic.js/03_ConversionOperation.js |
Arithmetic operators, negative values, and type conversion logic. | ✅ Stable |
| Comparisons & Logic | BackToBasic.js/04_Comprision.js, Cohort/06-conditional.js |
Equality (==, ===), relational operators, and conditional flow control. |
✅ Stable |
| Strings | BackToBasic.js/05_Strings.js, Cohort/05-Strings.js |
Template literals, string methods, and Unicode handling. | ✅ Stable |
| Numbers & Math | BackToBasic.js/06_NumbsAndMaths.js, Cohort/04-number.js |
Number object, locale formatting, and numeric utilities. |
✅ Stable |
| Dates & Time | BackToBasic.js/07_Dates.js |
Date object manipulation and formatting. | ✅ Stable |
| Arrays & Methods | BackToBasic.js/08_Array.js, Cohort/07-array.js, 08-array-methods.js |
Creation, iteration, and higher‑order methods. | ✅ Stable |
| Objects & Prototypes | Cohort/09-objects.js, 10-Object-Methods.js, 13-new.js, 14-prototype.js |
Literal objects, constructors, method definitions, and prototype chain. | ✅ Stable |
this & Context |
Cohort/11-this.js, 12-call-bind-apply.js |
Context binding patterns and function methods. | ✅ Stable |
| Classes & Inheritance | Cohort/15-Classes.js |
ES6 class syntax, constructors, and inheritance. | ✅ Stable |
| Symbols | Cohort/16-symbol.js |
Unique identifiers and well‑known symbols. | ✅ Stable |
| Cohort Index | Cohort/index.js |
Small demo of variable declarations. | ✅ Stable |
| Web Integration | Namaste JavaScript/index.html |
Basic HTML structure for executing JavaScript in a browser environment. | ✅ Stable |
| Layer | Technology | Reason |
|---|---|---|
| Runtime | Node.js (v14+) | Executes all examples without a browser. |
| Language | JavaScript (ES2022) | Modern syntax (let/const, arrow functions, classes). |
| Package Manager | npm (optional) | For installing development tools (e.g., ESLint). |
| Container (optional) | DevContainer (.devcontainer/devcontainer.json) |
Provides a ready‑to‑code VS Code environment. |
Js/
├─ .devcontainer/ # VS Code DevContainer definition
├─ .github/ # GitHub config (Dependabot)
├─ 01_basic/ # Very first “Hello World” style script
├─ BackToBasic.js/ # Core fundamentals (variables → maths)
│ ├─ 01_Varialble.js
│ ├─ 02_datatypes.js
│ ├─ 03_ConversionOperation.js
│ ├─ 04_Comprision.js
│ ├─ 05_Strings.js
│ ├─ 06_NumbsAndMaths.js
│ ├─ datatypes_symry.js
│ └─ hello.js
└─ Cohort/ # Structured lesson files used in a cohort setting
├─ 01-console.js
├─ 02-variables.js
├─ … (01‑16)
├─ README.md # Cohort‑specific readme
├─ index.js
└─ tempCodeRunnerFile.js
Each file is a self‑contained example that can be executed with node <path>.
| Tool | Minimum Version |
|---|---|
| Git | 2.20+ |
| Node.js | 14.x (LTS) |
| npm (bundled with Node) | 6.x+ |
| VS Code (optional) | 1.70+ (for DevContainer) |
# 1️⃣ Clone the repository
git clone https://github.com/imaakarsh/Js.git
cd Js
# 2️⃣ (Optional) Install dev dependencies for linting / testing
npm installnode -v # should print v14.x or newer
npm -v # should print a version >=6To run a script using Node.js:
bash node "Namaste JavaScript/index.js"
To view browser-based examples, open the HTML file in your browser:
bash
open "Namaste JavaScript/index.html"
start "Namaste JavaScript/index.html"
node BackToBasic.js/06_NumbsAndMaths.js
**Expected output**
400 [Number: 100] 3 10,000
### Quick reference for the most popular snippets
| Command | What you’ll see |
|---------|-----------------|
| `node 01_basic/test.js` | Simple `console.log('Hello World')` |
| `node BackToBasic.js/05_Strings.js` | String concatenation, template literals, length, etc. |
| `node Cohort/15-Classes.js` | Class definition, inheritance, method overriding |
| `node Cohort/12-call-bind-apply.js` | Demonstrates `call`, `apply`, `bind` usage |
### Running all examples automatically (optional)
```bash
# Bash loop – prints a header before each file
for f in $(git ls-files '*.js' | grep -v 'node_modules'); do
echo "=== $f ==="
node "$f"
echo
done
node BackToBasic.js/06_NumbsAndMaths.js
**Expected output**
400 [Number: 100] 3 10,000
### Quick reference for the most popular snippets
| Command | What you’ll see |
|---------|-----------------|
| `node 01_basic/test.js` | Simple `console.log('Hello World')` |
| `node BackToBasic.js/05_Strings.js` | String concatenation, template literals, length, etc. |
| `node Cohort/15-Classes.js` | Class definition, inheritance, method overriding |
| `node Cohort/12-call-bind-apply.js` | Demonstrates `call`, `apply`, `bind` usage |
### Running all examples automatically (optional)
```bash
# Bash loop – prints a header before each file
for f in $(git ls-files '*.js' | grep -v 'node_modules'); do
echo "=== $f ==="
node "$f"
echo
done
- Open the repository folder in VS Code.
- When prompted, click Reopen in Container.
- The container will install Node.js and expose a terminal ready for you.
npm run lint # runs ESLint (configured in package.json)
npm run format # runs Prettier(If package.json does not exist yet, you can initialise one with npm init -y and add ESLint/Prettier as dev dependencies.)
The repo currently contains no automated tests, but you can add Jest or Mocha tests for any file:
npm install --save-dev jest
npx jest- Use
constfor values that never change,letfor re‑assignable variables. - Prefer arrow functions for callbacks unless you need a custom
this. - Follow the Airbnb JavaScript Style Guide (or your own team’s guide).
This repository is educational material and does not require deployment.
If you wish to host the examples on a static site (e.g., GitHub Pages), you can:
- Convert each
.jsfile into an HTML page with a<script>tag. - Push the generated
docs/folder to thegh-pagesbranch.
Not applicable. The repository consists of independent scripts, not a reusable library or HTTP service.
We welcome contributions of any kind—new examples, typo fixes, or improved documentation.
- Fork the repository.
- Create a branch for your change:
git checkout -b feature/awesome-example. - Add / modify files. Keep the same folder organization (e.g., new topic → new file in
BackToBasic.js/orCohort/). - Run the linter (
npm run lint) and ensure the script runs without errors. - Commit with a clear message:
git commit -m "Add example for Set & WeakSet" - Push to your fork and open a Pull Request against
main.
- Code follows the project's style guide.
- Example runs successfully (
node <file>). - README (or relevant section) updated if a new topic is added.
- No sensitive information (API keys, passwords) is committed.
| Problem | Solution |
|---|---|
node: command not found |
Install Node.js from https://nodejs.org and ensure it’s on your PATH. |
Script prints undefined or throws ReferenceError |
Verify you’re using the correct file path and that the file contains valid JavaScript. |
| VS Code DevContainer fails to start | Make sure Docker Desktop is running and that you have at least 2 GB of RAM allocated to Docker. |
Linter errors about no‑undef |
Ensure you declared variables with let/const before using them. |
FAQ
Q: Do I need a package manager?
A: Only if you want to use the optional linting/formatting tools. The core examples run with plain Node.js.
Q: Can I run these examples in a browser?
A: Yes, but you’ll need to wrap them in <script> tags or use a bundler like Webpack/Vite.
| Milestone | Target Date | Description |
|---|---|---|
| v1.1 | Q3 2026 | Add a package.json with scripts (lint, format, test). |
| v1.2 | Q4 2026 | Introduce a small interactive web UI to browse examples. |
| v2.0 | 2027 | Convert the collection into an npm package (js‑playground) with exported utility functions. |
| Community | Ongoing | Accept community‑submitted examples for newer ECMAScript features (e.g., async/await, Proxy). |
License: MIT © 2026 Akarsh Kumar
| Name | GitHub |
|---|---|
| Akarsh Kumar | imaakarsh |
- Inspired by the classic “JavaScript for Beginners” tutorials.
- Thanks to the open‑source community for tools like Node.js, ESLint, and Prettier.