-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path1b-fundamental-var.js
More file actions
51 lines (40 loc) · 1.37 KB
/
1b-fundamental-var.js
File metadata and controls
51 lines (40 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
"use strict";
// variable is such like a storage
// declare first (let) and change value without redeclare
let tong = 300;
tong = 400; // True
// let tong = 399; // false bcoz redeclare tong
// var adalah keyword sama dg let
// var adalah bentuk old- legacy way. leave it
// variable naming
// a. hanya berisi huruf, angka atau simbol $ dan _
// b. first char gaboleh angka
// c. pake camelCase. semua kata diawali kapital kcuali kata pertama
// example: let userNames; let tes123;
// d. sensitive-case
let $ = 100;
console.log($);
let _ = 120;
console.log(_);
// asignment using reserved words
// let let = 30;
// wrong brooooo
// let return = 12;
// console.log(return);
// output : unexpected strict mode reserved word "return"
// numm = 5; // able not asignment using let in old time, but unable if used in strict mode
// console.log(numm); //referenceError
const alpha =30;
// alpha = 22;
console.log(alpha); //typeError assignment to constant var is error
// make constan name with all capital letter
const COLOR_RED = "#f00";
let colorku= COLOR_RED;
console.log(colorku);
// you cant re-declare a constant
const KONST = 19.35;
// KONST = 20; redeclaring is forbidden for const
console.log(KONST);
// actually constants used for aliases the hard-coded value
// daripada pakai value #F00, mending simpan value tsb ke COLOR_RED
// untuk menghindari misstype saat memanggil berulang-ulang.