JavaScript Fundamentals
JavaScript Basics
JavaScript Basics
Section titled “JavaScript Basics”Master the building blocks of JavaScript programming.
Variables
Section titled “Variables”// let - can be reassignedlet count = 0;count = 1;
// const - cannot be reassignedconst PI = 3.14159;// PI = 3; // Error!
// var - old way (avoid in modern JS)var oldStyle = "legacy";Data Types
Section titled “Data Types”// Primitive typeslet str = "Hello"; // Stringlet num = 42; // Numberlet bool = true; // Booleanlet undef = undefined; // Undefinedlet nothing = null; // Nulllet sym = Symbol("id"); // Symbollet big = 9007199254740991n; // BigInt
// Reference typeslet arr = [1, 2, 3]; // Arraylet obj = { name: "Alice", age: 25 }; // Objectlet func = function() {}; // FunctionOperators
Section titled “Operators”// Arithmeticlet sum = 5 + 3; // 8let diff = 5 - 3; // 2let prod = 5 * 3; // 15let quot = 5 / 3; // 1.666...let rem = 5 % 3; // 2let pow = 5 ** 3; // 125
// Comparison5 == "5" // true (loose equality)5 === "5" // false (strict equality - preferred!)5 !== "5" // true
// Logicaltrue && false // falsetrue || false // true!true // falseStrings
Section titled “Strings”let name = "Alice";let greeting = `Hello, ${name}!`; // Template literal
// String methods"hello".toUpperCase(); // "HELLO"" hello ".trim(); // "hello""hello".includes("ell"); // true"hello".split(""); // ["h","e","l","l","o"]Next Steps
Section titled “Next Steps”Continue learning JavaScript with arrays, objects, and functions!
Tutorials