JavaScript Fundamentals
Learn core JavaScript concepts including variables, functions, arrays, and objects for building interactive web apps.
0 of 10 concepts completed (0%)
What You'll Learn
Tutorial Contents
1.Variables, Types & Scope
// Three ways to declare use const unless you need to reassign
const PI = 3.14159; // immutable binding (block-scoped)
let count = 0; // mutable (block-scoped)// Primitive types typeof "hello" // "string" typeof 42 // "number" typeof true // "boolean" typeof undefined // "undefined" typeof null // "object" (historical bug!) typeof {} // "object"
// Always use strict equality 0 == false // true (type coercion avoid!) 0 === false // false (strict always use this)
// Closures inner function accesses outer scope function makeCounter(start = 0) { let count = start; return { increment: () => ++count, decrement: () => --count, value: () => count, }; } const counter = makeCounter(10); counter.increment(); // 11 counter.value(); // 11 ```
2.Arrays & Objects
// Functional array methods const doubled = numbers.map(n => n * 2); const evens = numbers.filter(n => n % 2 === 0); const sum = numbers.reduce((acc, n) => acc + n, 0); const found = numbers.find(n => n > 5); // first match const hasLarge = numbers.some(n => n > 8); // true if any match const allPos = numbers.every(n => n > 0); // true if all match
// Destructuring const [first, second, ...rest] = [1, 2, 3, 4, 5]; const { name, age, role = "user" } = user; const { address: { city } } = nested;
// Spread const merged = { ...defaults, ...override }; const copy = [...arr1, ...arr2];
// Object methods Object.keys(obj) // ['name', 'age'] Object.values(obj) // ['Sufi', 30] Object.entries(obj) // [['name','Sufi'],['age',30]] ```
3.Modern Syntax: Optional Chaining & More
// Optional chaining eliminates "Cannot read property of null"
const city = user?.address?.city; // undefined if any null
const first = arr?.[0]; // safe array access// Nullish coalescing only falls back for null/undefined (not 0 or "") const name = user.name ?? "Anonymous"; const count = data.count ?? 0;
// Template literals
const message =
Dear ${user.name},
Your order #${order.id} has shipped.
;
// Computed property names
const key = "dynamic";
const obj = { [key]: "value", [${key}_id]: 42 };
// Short-circuit evaluation
const isLoggedIn = true;
const display = isLoggedIn &&
Code Example
// Variables
const name = "Sufi";
let count = 0;
// Arrow function
const greet = (name) => `Hello, ${name}!`;
// Array methods
const nums = [1, 2, 3, 4, 5];
const doubled = nums.map(n => n * 2);
const evens = nums.filter(n => n % 2 === 0);
const sum = nums.reduce((acc, n) => acc + n, 0);
// Destructuring
const { title, year } = { title: "App", year: 2025 };Pro Tips
- 1Use const by default, let when you need to reassign, and never use var. This prevents accidental re-declarations and makes scoping predictable.
- 2Optional chaining (?.) and nullish coalescing (??) eliminate most null-check boilerplate. Learn them early.
- 3Arrow functions don't have their own 'this' they inherit from the enclosing scope. This matters inside class methods and event handlers.
- 4Master Array.prototype methods: map, filter, reduce, find, some, every. Once fluent, most for-loops become unnecessary.
Topics Covered
Continue Learning
Explore the official documentation and deepen your knowledge with real-world practice.
Explore the Full Portfolio
This is the complete portfolio of Sufi Khan Sulaiman, a technology leader specialising in B2B commerce and digital automation. Start from the Home page for the overview, then move through two decades of career experience across FLIR Systems, Lorex Technology, and 1c Platform, and the full catalogue of project case studies spanning headless commerce migrations, AI recommendation engines, and multi-channel fulfilment systems.
The skills and certifications page maps the technical and leadership capabilities behind the work, while the articles and the knowledge base break down the thinking into actionable frameworks. For hands-on learning, the tutorials and applications sections cover practical builds from front-end fundamentals to full-stack web apps.
For consulting engagement, the expertise page outlines service offerings, the ecommerce hub covers platform architecture and automation strategy, and the ecommerce guide (PDF) is a downloadable 55-page field manual. When you are ready to talk, the contact page is the direct line.