Skip to content

Commit 94ce660

Browse files
committed
feat(i18n): 1.02.16.article
1 parent 5d3005f commit 94ce660

File tree

1 file changed

+65
-65
lines changed
  • 1-js/02-first-steps/16-javascript-specials

1 file changed

+65
-65
lines changed

1-js/02-first-steps/16-javascript-specials/article.md

Lines changed: 65 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -63,57 +63,57 @@ Lebih lanjut di: <info:strict-mode>.
6363

6464
## Variabel
6565

66-
Can be declared using:
66+
Bisa dideklarasi menggunakan:
6767

6868
- `let`
69-
- `const` (constant, can't be changed)
70-
- `var` (old-style, will see later)
69+
- `const` (konstan, tak bisa berubah)
70+
- `var` (kuno, akan lihat kemudian)
7171

72-
A variable name can include:
73-
- Letters and digits, but the first character may not be a digit.
74-
- Characters `$` and `_` are normal, on par with letters.
75-
- Non-Latin alphabets and hieroglyphs are also allowed, but commonly not used.
72+
Nama variabel bisa mengandung:
73+
- Huruf dan digit, tapi karakter pertama bisa tak boleh digit.
74+
- Karakter `$` dan `_` itu normal, setara dengan huruf.
75+
- Alfabet non-latin dan hieroglyph juga boleh, tapi jarang dipakai.
7676

77-
Variables are dynamically typed. They can store any value:
77+
Variabel adalah tipe dinamis. Mereka bisa menyimpan nilai apapun:
7878

7979
```js
8080
let x = 5;
8181
x = "John";
8282
```
8383

84-
There are 7 data types:
84+
Ada 7 tipe data:
8585

86-
- `number` for both floating-point and integer numbers,
87-
- `string` for strings,
88-
- `boolean` for logical values: `true/false`,
89-
- `null` -- a type with a single value `null`, meaning "empty" or "does not exist",
90-
- `undefined` -- a type with a single value `undefined`, meaning "not assigned",
91-
- `object` and `symbol` -- for complex data structures and unique identifiers, we haven't learnt them yet.
86+
- `number` untuk angka floating-point dan integer,
87+
- `string` untuk string,
88+
- `boolean` untuk nilai logika: `true/false`,
89+
- `null` -- tipe dengan nilai tunggal `null`, artinya "kosong" atau "tidak eksis",
90+
- `undefined` -- tipe dengan nilai tunggal `undefined`, artinya "tak ditetapkan",
91+
- `object` dan `symbol` -- untuk struktur data komplex dan identifier unik, kita belum mempelajari mereka sekarang.
9292

93-
The `typeof` operator returns the type for a value, with two exceptions:
93+
Operator `typeof` mengembalikan tipe untuk satu nilai, dengan dua pengecualian:
9494
```js
95-
typeof null == "object" // error in the language
96-
typeof function(){} == "function" // functions are treated specially
95+
typeof null == "object" // galat di bahasa
96+
typeof function(){} == "function" // fungsi diperlakukan spesial
9797
```
9898

99-
More in: <info:variables> and <info:types>.
99+
Lebih lanjut di: <info:variables> and <info:types>.
100100

101-
## Interaction
101+
## Interaksi
102102

103-
We're using a browser as a working environment, so basic UI functions will be:
103+
Kita menggunakan peramban sebagai lingkungan kerja, jadi fungsi UI dasar akan menjadi:
104104

105105
[`prompt(question, [default])`](mdn:api/Window/prompt)
106-
: Ask a `question`, and return either what the visitor entered or `null` if they clicked "cancel".
106+
: Menanyakan `question`, dan mengembalikan apa yang pengunjung isikan atau `null` jika mereka mengklik "cancel".
107107

108108
[`confirm(question)`](mdn:api/Window/confirm)
109-
: Ask a `question` and suggest to choose between Ok and Cancel. The choice is returned as `true/false`.
109+
: Menanyakan `question` dan menyarakan memilih antara Ok dan Cancel. Pilihannya dikembalikan sebagai `true/false`.
110110

111111
[`alert(message)`](mdn:api/Window/alert)
112-
: Output a `message`.
112+
: Menampilkan a `message`.
113113

114-
All these functions are *modal*, they pause the code execution and prevent the visitor from interacting with the page until they answer.
114+
Semua fungsi ini adalah *modal*, mereka menyela exekusi kode dan mencegah pengunjung dari berinteraksi dengan laman hingga mereka menjawab.
115115

116-
For instance:
116+
Misalnya:
117117

118118
```js run
119119
let userName = prompt("Your name?", "Alice");
@@ -123,14 +123,14 @@ alert( "Visitor: " + userName ); // Alice
123123
alert( "Tea wanted: " + isTeaWanted ); // true
124124
```
125125

126-
More in: <info:alert-prompt-confirm>.
126+
Lebih lanjut di: <info:alert-prompt-confirm>.
127127

128-
## Operators
128+
## Operator
129129

130-
JavaScript supports the following operators:
130+
JavaScript mendukung operator berikut:
131131

132-
Arithmetical
133-
: Regular: `* + - /`, also `%` for the remainder and `**` for power of a number.
132+
Arithmatika
133+
: Regular: `* + - /`, juga `%` untuk remainder dan `**` untuk pangkat bilangan.
134134

135135
The binary plus `+` concatenates strings. And if any of the operands is a string, the other one is converted to string too:
136136

@@ -139,19 +139,19 @@ Arithmetical
139139
alert( 1 + '2' ); // '12', string
140140
```
141141

142-
Assignments
143-
: There is a simple assignment: `a = b` and combined ones like `a *= 2`.
142+
Penetapan
143+
: Ada penetapan simpel: `a = b` dan penetapan kombinasi seperti `a *= 2`.
144144

145145
Bitwise
146-
: Bitwise operators work with 32-bit integers at the lowest, bit-level: see the [docs](mdn:/JavaScript/Reference/Operators/Bitwise_Operators) when they are needed.
146+
: Operator bitwise bekerja dengan integer 32-bit di bit-level paling kecil: lihat [docs](mdn:/JavaScript/Reference/Operators/Bitwise_Operators) ketika mereka dibutuhkan.
147147

148-
Conditional
149-
: The only operator with three parameters: `cond ? resultA : resultB`. If `cond` is truthy, returns `resultA`, otherwise `resultB`.
148+
Kondisional
149+
: Satu-satunya operator dengan tiga parameter: `cond ? resultA : resultB`. Jika `cond` truthy, mengembalikan `resultA`, jika tidak `resultB`.
150150

151-
Logical operators
152-
: Logical AND `&&` and OR `||` perform short-circuit evaluation and then return the value where it stopped. Logical NOT `!` converts the operand to boolean type and returns the inverse value.
151+
Operator logika
152+
: Logika AND `&&` dan OR `||` menyajikan evaluasi sirkuit-pendek dan mengembalikan nilai di mana ia berhenti. Logika NOT `!` mengkonversi operand ke tipe boolean dan mengembalikan nilai kebalikannya.
153153

154-
Comparisons
154+
Pembandingan
155155
: Equality check `==` for values of different types converts them to a number (except `null` and `undefined` that equal each other and nothing else), so these are equal:
156156

157157
```js run
@@ -172,9 +172,9 @@ Other operators
172172

173173
More in: <info:operators>, <info:comparison>, <info:logical-operators>.
174174

175-
## Loops
175+
## Loop
176176

177-
- We covered 3 types of loops:
177+
- Kita meliput 3 tipe loop:
178178

179179
```js
180180
// 1
@@ -193,25 +193,25 @@ More in: <info:operators>, <info:comparison>, <info:logical-operators>.
193193
}
194194
```
195195

196-
- The variable declared in `for(let...)` loop is visible only inside the loop. But we can also omit `let` and reuse an existing variable.
197-
- Directives `break/continue` allow to exit the whole loop/current iteration. Use labels to break nested loops.
196+
- Variabel yang dideklarasi di loop `for(let...)` terlihat cuma di dalam loop. Tapi kita juga bisa membuang `let` dan memakai kembali variabel yang sudah eksis.
197+
- Directive `break/continue` membolehkan untuk keluar iterasi loop/current. Guakan label untuk menghancurkan loop bersarang.
198198

199-
Details in: <info:while-for>.
199+
Detil di: <info:while-for>.
200200

201-
Later we'll study more types of loops to deal with objects.
201+
Nanti kita akan pelajari tipe loop lainnya untuk berhadapan dengan object.
202202

203-
## The "switch" construct
203+
## Konstruksi "switch"
204204

205-
The "switch" construct can replace multiple `if` checks. It uses `===` (strict equality) for comparisons.
205+
Konstruksi "switch" bisa mengganti pengecekan ganda `if`. Ia memakai `===` (ekualitas ketat) untuk pembandingan.
206206

207-
For instance:
207+
Misalnya:
208208

209209
```js run
210210
let age = prompt('Your age?', 18);
211211
212212
switch (age) {
213213
case 18:
214-
alert("Won't work"); // the result of prompt is a string, not a number
214+
alert("Won't work"); // hasil prompt ialah string, bukan angka
215215
216216
case "18":
217217
alert("This works!");
@@ -222,13 +222,13 @@ switch (age) {
222222
}
223223
```
224224

225-
Details in: <info:switch>.
225+
Detal di: <info:switch>.
226226

227-
## Functions
227+
## Fungsi
228228

229-
We covered three ways to create a function in JavaScript:
229+
Kita meliput tiga cara membuat fungsi di JavaScript:
230230

231-
1. Function Declaration: the function in the main code flow
231+
1. Deklarasi Fungsi: fungsi di aliran kode utama
232232

233233
```js
234234
function sum(a, b) {
@@ -238,7 +238,7 @@ We covered three ways to create a function in JavaScript:
238238
}
239239
```
240240

241-
2. Function Expression: the function in the context of an expression
241+
2. Expresi Fungsi: fungsi di dalam kontex expresi
242242

243243
```js
244244
let sum = function(a, b) {
@@ -248,32 +248,32 @@ We covered three ways to create a function in JavaScript:
248248
};
249249
```
250250

251-
3. Arrow functions:
251+
3. Fungsi panah:
252252

253253
```js
254-
// expression at the right side
254+
// expresi di sisi kanan
255255
let sum = (a, b) => a + b;
256256
257-
// or multi-line syntax with { ... }, need return here:
257+
// atau syntax baris-ganda dengan { ... }, butuh kembalian di sini:
258258
let sum = (a, b) => {
259259
// ...
260260
return a + b;
261261
}
262262
263-
// without arguments
263+
// tanpa argumen
264264
let sayHi = () => alert("Hello");
265265
266-
// with a single argument
266+
// dengan argumen tunggal
267267
let double = n => n * 2;
268268
```
269269

270270

271-
- Functions may have local variables: those declared inside its body. Such variables are only visible inside the function.
272-
- Parameters can have default values: `function sum(a = 1, b = 2) {...}`.
273-
- Functions always return something. If there's no `return` statement, then the result is `undefined`.
271+
- Fungsi bisa punya variabel lokal: mereka yang dideklarasi dalam badannya. Variabel macam itu cuma terlihat di dalam fungsi.
272+
- Parameter bisa punya nilai default: `function sum(a = 1, b = 2) {...}`.
273+
- Fungsi selalu mengembalikan sesuatu. Jika tak ada pernyataan `return`, maka kembaliannya `undefined`.
274274

275-
Details: see <info:function-basics>, <info:function-expressions-arrows>.
275+
Detil: lihat <info:function-basics>, <info:function-expressions-arrows>.
276276

277-
## More to come
277+
## Lebih banyak yang akan datang
278278

279-
That was a brief list of JavaScript features. As of now we've studied only basics. Further in the tutorial you'll find more specials and advanced features of JavaScript.
279+
Ini daftar ringkas fitur JavaScript. Untuk sekarang kita belajar hanya dasar. Kemudian di tutorial nanti kamu akan menemui fitur JavaScript yang lebih canggih dan spesial.

0 commit comments

Comments
 (0)