Loading page...
Loading page...
Understand how computers store values in temporary memory using let and const variable declarations.
Computers use temporary memory (RAM) to hold data during program execution. In code, we assign labels to these memory slots using variables.
Use const when a value must remain immutable after declaration (constant and protected against accidental overwrites).
Use let when the value will change or be recalculated during program execution.
Avoid the legacy var keyword because its loose scoping rules frequently lead to subtle bugs in modern applications.
Imagine a desk drawer. The label sticker on the drawer front is the variable name (for example, hargaBuku), and what sits inside is its value (15000). If the drawer is sealed with permanent tape (const), you cannot swap its contents. If it is a normal sliding drawer (let), you can update what sits inside at any time.