|
1 | | -# Data types |
| 1 | +# Tipe data |
2 | 2 |
|
3 | | -A variable in JavaScript can contain any data. A variable can at one moment be a string and at another be a number: |
| 3 | +Variabel di JavaScript bisa mengandung data apapun. Satu variabel awalnya string bisa berubah jadi angka: |
4 | 4 |
|
5 | 5 | ```js |
6 | 6 | // no error |
7 | 7 | let message = "hello"; |
8 | 8 | message = 123456; |
9 | 9 | ``` |
10 | 10 |
|
11 | | -Programming languages that allow such things are called "dynamically typed", meaning that there are data types, but variables are not bound to any of them. |
| 11 | +Bahasa pemrograman yang memperbolehkan hal semacam ini dibsebut "dynamically typed", yang artinya ada tipe data, tapi variabel tak terikat ke tipe data apapun. |
12 | 12 |
|
13 | | -There are seven basic data types in JavaScript. Here, we'll cover them in general and in the next chapters we'll talk about each of them in detail. |
| 13 | +Ada tujuh tipe data dasar di JavaScript. Di sini, kita akan mengcover mereka secara umum dan di bab berikutnya kita akan berbicara tentang setiap dari mereka secara detil. |
14 | 14 |
|
15 | | -## A number |
| 15 | +## Angka |
16 | 16 |
|
17 | 17 | ```js |
18 | 18 | let n = 123; |
19 | 19 | n = 12.345; |
20 | 20 | ``` |
21 | 21 |
|
22 | | -The *number* type represents both integer and floating point numbers. |
| 22 | +Tipe *angka* merepresentasikan baik angka integer maupun floating point. |
23 | 23 |
|
24 | | -There are many operations for numbers, e.g. multiplication `*`, division `/`, addition `+`, subtraction `-`, and so on. |
| 24 | +Ada banyak operasi untuk angka, misal perkalian `*`, pembagian `/`, penambahan `+`, pengurangan `-`, dan lainnya. |
25 | 25 |
|
26 | 26 | Besides regular numbers, there are so-called "special numeric values" which also belong to this data type: `Infinity`, `-Infinity` and `NaN`. |
27 | 27 |
|
@@ -64,19 +64,19 @@ We'll see more about working with numbers in the chapter <info:number>. |
64 | 64 |
|
65 | 65 | ## A string |
66 | 66 |
|
67 | | -A string in JavaScript must be surrounded by quotes. |
| 67 | +String di JavaScript harus dikelilingi petik. |
68 | 68 |
|
69 | 69 | ```js |
70 | 70 | let str = "Hello"; |
71 | 71 | let str2 = 'Single quotes are ok too'; |
72 | 72 | let phrase = `can embed ${str}`; |
73 | 73 | ``` |
74 | 74 |
|
75 | | -In JavaScript, there are 3 types of quotes. |
| 75 | +Di JavaScript, ada 3 tipe petik. |
76 | 76 |
|
77 | | -1. Double quotes: `"Hello"`. |
78 | | -2. Single quotes: `'Hello'`. |
79 | | -3. Backticks: <code>`Hello`</code>. |
| 77 | +1. Petik ganda: `"Hello"`. |
| 78 | +2. Petik tunggal: `'Hello'`. |
| 79 | +3. Backtick: <code>`Hello`</code>. |
80 | 80 |
|
81 | 81 | Double and single quotes are "simple" quotes. There's no difference between them in JavaScript. |
82 | 82 |
|
|
0 commit comments