HTML → 負責結構
CSS → 負責樣式
JavaScript (JS) → 負責行為與互動
沒有 JS,網頁就像是一本靜態書;有了 JS,它才能變成「應用程式」。
var name = "Alice"; // 古老用法,不推薦
let age = 20; // 可變的變數
const pi = 3.14; // 常數,不能被重新指定
let message = "Hello World";
console.log(message); // 輸出:Hello World
let text = "Hello";
let text2 = 'World';
let text3 = `Hi, ${text2}`; // 模板字串
let a = 10;
let b = 3.14;
let isLogin = true;
let isAdmin = false;
let x; // 預設是 undefined
let y = null; // 表示「空值」
let big = 123456789012345678901234567890n;
console.log(typeof "Hello"); // string
console.log(typeof 123); // number
console.log(typeof true); // boolean
console.log(typeof undefined); // undefined
console.log(typeof null); // object (JS 的小 bug XD)
username
,賦值為你的名字,並在 console.log() 輸出。height
、weight
、bmi
,嘗試計算 BMI(體重 / 身高平方)。typeof
測試不同型別的變數。👉 明天(Day 12),我們會進入 JavaScript 運算子與條件判斷,讓程式能做「邏輯選擇」。