// let — ပြောင်းနိုင်တဲ့ variable (recommended) let name = "Ko Min" let age = 25 let isStudent = true // const — မပြောင်းနိုင်တဲ့ constant const PI = 3.14159 const SITE_NAME = "My Website" // var — old way (avoid using) var oldVar = "I'm old" // ============================= // let ကို ပြောင်းနိုင်: let score = 0 score = 100 // ✅ OK // const ကို မပြောင်းရ: const MAX = 100 // MAX = 200 // ❌ Error!
let + const ပဲ သုံးပါ — var ကို ရှောင်ပါ
// String (text)
let str1 = "Hello" // double quote
let str2 = 'World' // single quote
let str3 = `Hi ${name}` // template literal
// Number
let int = 42
let float = 3.14
let neg = -10
// Boolean
let isTrue = true
let isFalse = false
// null — intentionally empty
let empty = null
// undefined — not assigned
let notSet
console.log(notSet) // undefined
// Object
let person = { name: "Min", age: 25 }
// Array
let fruits = ["apple", "banana", "mango"]
typeof "hello" // "string"
typeof 42 // "number"
typeof true // "boolean"
typeof undefined // "undefined"
typeof null // "object" ← JS bug (historical)
typeof {} // "object"
typeof [] // "object"
typeof function(){} // "function"
Value ထည့်ပြီး typeof ကြည့်ပါ:
let first = "Ko"
let last = "Min"
// Concatenation
let full = first + " " + last // "Ko Min"
// Template literal (better!)
let greeting = `Hello, ${first} ${last}!` // "Hello, Ko Min!"
// String methods
"hello".length // 5
"hello".toUpperCase() // "HELLO"
"hello".includes("ell") // true
"hello world".split(" ") // ["hello", "world"]
" hello ".trim() // "hello"
"hello".replace("l","r") // "herlo"
"hello".slice(1, 3) // "el"
Template Literal try:
// Arithmetic
10 + 3 // 13
10 - 3 // 7
10 * 3 // 30
10 / 3 // 3.333...
10 % 3 // 1 (remainder/modulo)
2 ** 10 // 1024 (power)
// Math object
Math.round(3.7) // 4
Math.floor(3.9) // 3
Math.ceil(3.1) // 4
Math.abs(-5) // 5
Math.max(1,5,3) // 5
Math.min(1,5,3) // 1
Math.random() // 0 to 1 random
// parseInt / parseFloat
parseInt("42px") // 42
parseFloat("3.14") // 3.14
Number("100") // 100
// == loose equality (type convert) 5 == "5" // true ← dangerous! 0 == false // true ← dangerous! null == undefined // true // === strict equality (type check too) 5 === "5" // false ← safer! 5 === 5 // true 0 === false // false // ❌ Avoid ==, ✅ Use === always
| Operator | Meaning | Example | Result |
|---|---|---|---|
=== | Strict equal | 5 === 5 | true |
!== | Strict not equal | 5 !== "5" | true |
> | Greater than | 10 > 5 | true |
< | Less than | 3 < 5 | true |
>= | Greater or equal | 5 >= 5 | true |
&& | AND | true && false | false |
|| | OR | true || false | true |
! | NOT | !true | false |
Next: JS Lesson 02 → Conditions →