Skip to content

Commit 951bfaf

Browse files
authored
Merge pull request #10 from SibianDG/variables
Variables
2 parents 410d922 + b6463f5 commit 951bfaf

File tree

17 files changed

+258
-280
lines changed

17 files changed

+258
-280
lines changed

1-js/02-first-steps/01-hello-world/1-hello-alert/index.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
<body>
55

66
<script>
7-
alert( "I'm JavaScript!" );
7+
alert( "Ik ben JavaScript!" );
88
</script>
99

1010
</body>
1111

12-
</html>
12+
</html>
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
2-
[html src="index.html"]
1+
2+
[html src="index.html"]

1-js/02-first-steps/01-hello-world/1-hello-alert/solution.view/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<body>
55

66
<script>
7-
alert( "I'm JavaScript!" );
7+
alert( "Ik ben JavaScript!" );
88
</script>
99

1010
</body>
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1-
importance: 5
1+
# Toon een waarschuwing
22

3-
---
3+
Maak een pagina aan met een bericht "Ik ben JavaScript!".
44

5-
# Show an alert
6-
7-
Create a page that shows a message "I'm JavaScript!".
8-
9-
Do it in a sandbox, or on your hard drive, doesn't matter, just ensure that it works.
5+
Doe het in een zandbak, of op je harde schijf, maakt niet uit, zorg er gewoon voor dat het werkt.
106

117
[demo src="solution"]
128

Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
alert("I'm JavaScript!");
1+
alert ("Ik ben JavaScript!");
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
The HTML code:
1+
De HTML-code:
22

33
[html src="index.html"]
44

5-
For the file `alert.js` in the same folder:
5+
Voor het bestand `alert.js` in dezelfde map:
66

77
[js src="alert.js"]
88

Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
importance: 5
1+
# Toon een waarschuwing met een extern script
22

3-
---
3+
Neem de oplossing van de vorige taak <info:task/hello-alert>. Wijzig het door de inhoud van het script uit te pakken in een extern bestand `alert.js`, dat zich in dezelfde map bevindt.
44

5-
# Show an alert with an external script
6-
7-
Take the solution of the previous task <info:task/hello-alert>. Modify it by extracting the script content into an external file `alert.js`, residing in the same folder.
8-
9-
Open the page, ensure that the alert works.
5+
Open de pagina, zorg ervoor dat de waarschuwing werkt.
+48-48
Original file line numberDiff line numberDiff line change
@@ -1,132 +1,132 @@
1-
# Hello, world!
1+
# Hallo, wereld!
22

3-
This part of the tutorial is about core JavaScript, the language itself.
3+
Dit deel van de tutorial gaat over de kern van JavaScript, de taal zelf.
44

5-
But we need a working environment to run our scripts and, since this book is online, the browser is a good choice. We'll keep the amount of browser-specific commands (like `alert`) to a minimum so that you don't spend time on them if you plan to concentrate on another environment (like Node.js). We'll focus on JavaScript in the browser in the [next part](/ui) of the tutorial.
5+
Maar we hebben een werkomgeving nodig om onze scripts uit te voeren en aangezien dit boek online is, is de browser een goede keuze. We zullen de hoeveelheid browser-specifieke commando's (zoals `alert`) tot een minimum beperken zodat je er geen tijd aan besteedt als je van plan bent je te concentreren op een andere omgeving (zoals Node.js). We zullen ons concentreren op JavaScript in de browser in het [next part](/ui) van de tutorial.
66

7-
So first, let's see how we attach a script to a webpage. For server-side environments (like Node.js), you can execute the script with a command like `"node my.js"`.
7+
Dus laten we eerst eens kijken hoe we een script aan een webpagina koppelen. Voor server-side omgevingen (zoals Node.js) kun je het script uitvoeren met een commando als `"node my.js"`.
88

99

10-
## The "script" tag
10+
## De "script" tag
1111

12-
JavaScript programs can be inserted into any part of an HTML document with the help of the `<script>` tag.
12+
JavaScript-programma's kunnen in elk deel van een HTML-document worden ingevoegd met behulp van de `<script>`-tag.
1313

14-
For instance:
14+
Bijvoorbeeld:
1515

1616
```html run height=100
1717
<!DOCTYPE HTML>
1818
<html>
1919

2020
<body>
2121

22-
<p>Before the script...</p>
22+
<p>Voor het script...</p>
2323

2424
*!*
2525
<script>
26-
alert( 'Hello, world!' );
26+
alert( 'Hallo, wereld!' );
2727
</script>
2828
*/!*
2929

30-
<p>...After the script.</p>
30+
<p>...Na het script.</p>
3131

3232
</body>
3333

3434
</html>
3535
```
3636

3737
```online
38-
You can run the example by clicking the "Play" button in the right-top corner of the box above.
38+
U kunt het voorbeeld uitvoeren door te klikken op de knop "Afspelen" in de rechterbovenhoek van het vak hierboven.
3939
```
4040

41-
The `<script>` tag contains JavaScript code which is automatically executed when the browser processes the tag.
41+
Het `<script>`-tag bevat JavaScript-code die automatisch wordt uitgevoerd wanneer de browser de tag verwerkt.
4242

4343

44-
## Modern markup
44+
## Moderne opmaak
4545

46-
The `<script>` tag has a few attributes that are rarely used nowadays but can still be found in old code:
46+
Het `<script>` tag heeft een aantal attributen die tegenwoordig zelden gebruikt worden, maar nog wel in oude code te vinden zijn:
4747

48-
The `type` attribute: <code>&lt;script <u>type</u>=...&gt;</code>
49-
: The old HTML standard, HTML4, required a script to have a `type`. Usually it was `type="text/javascript"`. It's not required anymore. Also, the modern HTML standard totally changed the meaning of this attribute. Now, it can be used for JavaScript modules. But that's an advanced topic, we'll talk about modules in another part of the tutorial.
48+
Het `type`-attribuut: <code>&lt;script <u>type</u>=...&gt;</code>
49+
: De oude HTML-standaard, HTML4, vereiste een script om een `type` te hebben. Meestal was het `type="tekst/javascript"`. Het is niet meer nodig. Ook de moderne HTML-standaard heeft de betekenis van dit attribuut totaal veranderd. Nu kan het gebruikt worden voor JavaScript-modules. Maar dat is een geavanceerd onderwerp, we zullen het in een ander deel van de tutorial over modules hebben.
5050

51-
The `language` attribute: <code>&lt;script <u>language</u>=...&gt;</code>
52-
: This attribute was meant to show the language of the script. This attribute no longer makes sense because JavaScript is the default language. There is no need to use it.
51+
Het `taal`-attribuut: <code>&lt;script <u>taal</u>=...&gt;</code>
52+
: Dit attribuut was bedoeld om de taal van het script te laten zien. Dit attribuut heeft geen zin meer omdat JavaScript de standaard taal is. Het is niet nodig om het te gebruiken.
5353

54-
Comments before and after scripts.
55-
: In really ancient books and guides, you may find comments inside `<script>` tags, like this:
54+
Commentaar voor en na scripts.
55+
: In echt oude boeken en gidsen vind je misschien commentaar in `<script>`-tags, zoals deze:
5656

5757
```html no-beautify
58-
<script type="text/javascript"><!--
58+
<script type="tekst/javascript"><! --
5959
...
6060
//--></script>
6161
```
6262

63-
This trick isn't used in modern JavaScript. These comments hide JavaScript code from old browsers that didn't know how to process the `<script>` tag. Since browsers released in the last 15 years don't have this issue, this kind of comment can help you identify really old code.
63+
Deze truc wordt niet gebruikt in moderne JavaScript. Deze commentaren verbergen JavaScript-code voor oude browsers die niet wisten hoe ze de `<script>`-tag moesten verwerken. Aangezien browsers die in de afgelopen 15 jaar zijn uitgebracht dit probleem niet hebben, kan dit soort commentaar u helpen bij het identificeren van echt oude code.
6464

6565

66-
## External scripts
66+
## Externe scripts
6767

68-
If we have a lot of JavaScript code, we can put it into a separate file.
68+
Als we veel JavaScript-code hebben, kunnen we die in een apart bestand zetten.
6969

70-
Script files are attached to HTML with the `src` attribute:
70+
Scriptbestanden worden aan HTML gekoppeld met het `src` attribuut:
7171

7272
```html
73-
<script src="/path/to/script.js"></script>
73+
<script src="/pad/naar/script.js"></script>
7474
```
7575

76-
Here, `/path/to/script.js` is an absolute path to the script from the site root. One can also provide a relative path from the current page. For instance, `src="script.js"` would mean a file `"script.js"` in the current folder.
76+
Hier is `/pad/naar/script.js` een absoluut pad naar het script vanuit de site-root. Men kan ook een relatief pad van de huidige pagina opgeven. Bijvoorbeeld, `src="script.js "betekent een bestand `"script.js"` in de huidige map.
7777

78-
We can give a full URL as well. For instance:
78+
We kunnen ook een volledige URL geven. Bijvoorbeeld:
7979

8080
```html
8181
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.11/lodash.js"></script>
8282
```
8383

84-
To attach several scripts, use multiple tags:
84+
Om meerdere scripts te bevestigen, gebruik je meerdere tags:
8585

8686
```html
8787
<script src="/js/script1.js"></script>
8888
<script src="/js/script2.js"></script>
8989
9090
```
9191

92-
```smart
93-
As a rule, only the simplest scripts are put into HTML. More complex ones reside in separate files.
92+
```slimme
93+
In de regel worden alleen de eenvoudigste scripts in HTML gezet. Complexere scripts staan in aparte bestanden.
9494
95-
The benefit of a separate file is that the browser will download it and store it in its [cache](https://en.wikipedia.org/wiki/Web_cache).
95+
Het voordeel van een apart bestand is dat de browser het downloadt en opslaat in zijn [cache](https://en.wikipedia.org/wiki/Web_cache).
9696
97-
Other pages that reference the same script will take it from the cache instead of downloading it, so the file is actually downloaded only once.
97+
Andere pagina's die naar hetzelfde script verwijzen zullen het uit de cache halen in plaats van het te downloaden, zodat het bestand eigenlijk maar één keer wordt gedownload.
9898
99-
That reduces traffic and makes pages faster.
99+
Dat vermindert het verkeer en maakt de pagina's sneller.
100100
```
101101

102-
````warn header="If `src` is set, the script content is ignored."
103-
A single `<script>` tag can't have both the `src` attribute and code inside.
102+
````warn header="Als `src` is ingesteld, wordt de inhoud van het script genegeerd."
103+
Een enkele `<script>` tag kan niet zowel het `src` attribuut als de code bevatten.
104104

105-
This won't work:
105+
Dit werkt niet:
106106

107107
```html
108-
<script *!*src*/!*="file.js">
109-
alert(1); // the content is ignored, because src is set
108+
<script *! *src*/! *="file.js">
109+
waarschuwing(1); // de inhoud wordt genegeerd, omdat src is ingesteld
110110
</script>
111111
```
112112

113-
We must choose either an external `<script src="…">` or a regular `<script>` with code.
113+
We moeten kiezen voor een externe `<script src="...">" of een gewone `<script>` met code.
114114

115-
The example above can be split into two scripts to work:
115+
Het bovenstaande voorbeeld kan worden opgesplitst in twee scripts om te werken:
116116

117117
```html
118-
<script src="file.js"></script>
118+
<script src="bestand.js"></script>
119119
<script>
120-
alert(1);
120+
waarschuwing(1);
121121
</script>
122122
```
123123
````
124124
125-
## Summary
125+
## Samenvatting
126126
127-
- We can use a `<script>` tag to add JavaScript code to a page.
128-
- The `type` and `language` attributes are not required.
129-
- A script in an external file can be inserted with `<script src="path/to/script.js"></script>`.
127+
- We kunnen een `<script>` tag gebruiken om JavaScript-code toe te voegen aan een pagina.
128+
- De `type` en `taal` attributen zijn niet nodig.
129+
- Een script in een extern bestand kan worden ingevoegd met `<script src="path/to/script.js"></script>`.
130130
131131
132-
There is much more to learn about browser scripts and their interaction with the webpage. But let's keep in mind that this part of the tutorial is devoted to the JavaScript language, so we shouldn't distract ourselves with browser-specific implementations of it. We'll be using the browser as a way to run JavaScript, which is very convenient for online reading, but only one of many.
132+
Er is nog veel meer te leren over browserscripts en hun interactie met de webpagina. Maar laten we niet vergeten dat dit deel van de tutorial gewijd is aan de JavaScript-taal, dus we moeten onszelf niet afleiden met browser-specifieke implementaties ervan. We zullen de browser gebruiken als een manier om JavaScript uit te voeren, wat erg handig is voor online lezen, maar slechts één van de vele.
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
In the code below, each line corresponds to the item in the task list.
1+
In de onderstaande code komt elke regel overeen met het item in de takenlijst.
22

33
```js run
4-
let admin, name; // can declare two variables at once
4+
let admin, naam; // kan twee variabelen tegelijk aangeven
55

6-
name = "John";
6+
naam = "John";
77

8-
admin = name;
8+
admin = naam;
99

1010
alert( admin ); // "John"
11-
```
12-
11+
```
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
importance: 2
1+
# Werken met variabelen
22

3-
---
4-
5-
# Working with variables
6-
7-
1. Declare two variables: `admin` and `name`.
8-
2. Assign the value `"John"` to `name`.
9-
3. Copy the value from `name` to `admin`.
10-
4. Show the value of `admin` using `alert` (must output "John").
3+
1. Verklaar twee variabelen: `admin` en `naam`.
4+
2. Wijs de waarde `"John"` toe aan `naam`.
5+
3. Kopieer de waarde van `naam` naar `admin`.
6+
4. Toon de waarde van `admin` met behulp van `alert` (moet "John" aangeven).
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
## The variable for our planet
1+
## De variabele voor onze planeet
22

3-
That's simple:
3+
Dat is eenvoudig:
44

55
```js
6-
let ourPlanetName = "Earth";
6+
let onzePlanetNaam = "Aarde";
77
```
88

9-
Note, we could use a shorter name `planet`, but it might be not obvious what planet it refers to. It's nice to be more verbose. At least until the variable isNotTooLong.
9+
Let wel, we zouden een kortere naam `planeet` kunnen gebruiken, maar het is misschien niet duidelijk naar welke planeet het verwijst. Het is leuk om meer woorden te gebruiken. Tenminste tot de variabeleNietTeLang is.
1010

11-
## The name of the current visitor
11+
## De naam van de huidige bezoeker
1212

1313
```js
1414
let currentUserName = "John";
1515
```
1616

17-
Again, we could shorten that to `userName` if we know for sure that the user is current.
17+
Nogmaals, we zouden dat kunnen inkorten tot `userName` als we zeker weten dat de gebruiker actueel is.
1818

19-
Modern editors and autocomplete make long variable names easy to write. Don't save on them. A name with 3 words in it is fine.
19+
Moderne editors en autocompleteurs maken lange variabele namen gemakkelijk te schrijven. Bespaar er niet op. Een naam met 3 woorden is prima.
2020

21-
And if your editor does not have proper autocompletion, get [a new one](/code-editors).
21+
En als je editors geen goede autocompletion heeft, haal dan [een nieuwe](/code-editors).
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
importance: 3
1+
# Het geven van de juiste naam
22

3-
---
4-
5-
# Giving the right name
6-
7-
1. Create a variable with the name of our planet. How would you name such a variable?
8-
2. Create a variable to store the name of a current visitor to a website. How would you name that variable?
3+
1. Creëer een variabele met de naam van onze planeet. Hoe zou je zo'n variabele noemen?
4+
2. Maak een variabele aan om de naam van een huidige bezoeker van een website op te slaan. Hoe zou u die variabele een naam geven?
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
We generally use upper case for constants that are "hard-coded". Or, in other words, when the value is known prior to execution and directly written into the code.
1+
We gebruiken over het algemeen hoofdletters voor constanten die "hard-coded" zijn. Of, met andere woorden, wanneer de waarde voorafgaand aan de uitvoering bekend is en direct in de code wordt geschreven.
22

3-
In this code, `birthday` is exactly like that. So we could use the upper case for it.
3+
In deze code is `birthday` precies zo. We zouden dus de hoofdletters kunnen gebruiken.
44

5-
In contrast, `age` is evaluated in run-time. Today we have one age, a year after we'll have another one. It is constant in a sense that it does not change through the code execution. But it is a bit "less of a constant" than `birthday`: it is calculated, so we should keep the lower case for it.
5+
Daarentegen wordt `leeftijd` geëvalueerd in run-time. Vandaag hebben we één leeftijd, een jaar nadat we een andere zullen hebben. Het is constant in zekere zin dat het niet verandert door de uitvoering van de code. Maar het is een beetje "minder constant" dan `verjaardag`: het is berekend, dus we moeten de kleine letters ervoor houden.
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,19 @@
1-
importance: 4
1+
# Uppercase constante?
22

3-
---
4-
5-
# Uppercase const?
6-
7-
Examine the following code:
3+
Bestudeer de volgende code:
84

95
```js
10-
const birthday = '18.04.1982';
6+
const verjaardag = '18.04.1982';
117

12-
const age = someCode(birthday);
8+
const leeftijd = eenCode(verjaardag);
139
```
1410

15-
Here we have a constant `birthday` date and the `age` is calculated from `birthday` with the help of some code (it is not provided for shortness, and because details don't matter here).
11+
Hier hebben we een constante `verjaardag` datum en de `leeftijd` wordt berekend vanaf `verjaardag` met behulp van een of andere code (het is niet voorzien voor kortstondigheid, en omdat details hier niet van belang zijn).
1612

17-
Would it be right to use upper case for `birthday`? For `age`? Or even for both?
13+
Zou het juist zijn om hoofdletters te gebruiken voor `verjaardag`? Voor `leeftijd`? Of zelfs voor beide?
1814

1915
```js
20-
const BIRTHDAY = '18.04.1982'; // make uppercase?
21-
22-
const AGE = someCode(BIRTHDAY); // make uppercase?
23-
```
16+
const VERJAARDAG = '18.04.1982'; // uppercase maken?
2417

18+
const LEEFTIJD = eenCode(BIRTHDAY); // hoofdletters maken?
19+
```

0 commit comments

Comments
 (0)