Day 3: Primitive Data Types & typeof
Daily Objective
Section titled “Daily Objective”Master JavaScript’s core primitive types and inspect element types using the typeof operator.
1. The 5 Core Primitives
Section titled “1. The 5 Core Primitives”string: Text characters wrapped in quotes:'Hello',"World".number: Integers and floating-point decimals:42,3.14159,-10.boolean: Logical truth values:trueorfalse.undefined: A variable that has been declared but not yet assigned a value.null: An intentional assignment representing “no value” or “empty”.
const title = 'JavaScript Course';const price = 49.99;const isPublished = true;let discount; // undefinedconst coupon = null; // intentional empty value2. The typeof Operator
Section titled “2. The typeof Operator”console.log(typeof title); // "string"console.log(typeof price); // "number"console.log(typeof isPublished); // "boolean"console.log(typeof discount); // "undefined"console.log(typeof coupon); // "object" (historical JavaScript quirk!)Daily Hands-on Practice (70%)
Section titled “Daily Hands-on Practice (70%)”- Declare a variable for each primitive type and log its value along with its
typeof. - Observe what happens when you perform mathematical operations between numbers and strings like
'5' + 2vs'5' - 2.