You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Week0/README.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@ In week one we will discuss the following topics:
7
7
8
8
### Here are resources that we like you to read as a preparation for the coming lecture.
9
9
10
-
- In you next lecture **Unmesh** will give you your first Git session, please look through the [GIT](https://github.com/HackYourFuture/Gitrepository) and read the learning goals.
10
+
- In you next lecture **Unmesh** will give you your first Git session, please look through the [GIT](https://github.com/HackYourFuture/Git) repository and read the learning goals.
11
11
- Please watch [Up Running with Bash Scripting](https://www.lynda.com/Bash-tutorials/Up-Running-Bash-Scripting/142989-2.html)
12
12
as a recap on the cli classes you have had (1 hour and 25 min).
13
13
- Please watch the first 5 chapters of the [Git essential training](https://www.lynda.com/Git-tutorials/Git-Essential-Training/100222-2.html)
Copy file name to clipboardExpand all lines: Week1/REVIEW.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,21 +13,21 @@ This review covers:
13
13
14
14
Command Line Interface
15
15
16
-
[Read more...](../topics/CLI.md)
16
+
[Read more...](../fundamentals/CLI.md)
17
17
18
18
>:star: Highly recommended :star::take a look at the Command Line [repository](https://github.com/HackYourFuture/CommandLine) and especially review the preparations of the first lecture: https://github.com/HackYourFuture/CommandLine/blob/master/Lecture-1.md
19
19
20
20
## Variables
21
21
22
22
A "variable" is a place where you can store information, such as a string, or a number. A variable has a _name_ (that you choose) and a _value_. New variables in JavaScript are declared using one of three keywords: `let`, `const`, or `var`.
23
23
24
-
[Read more...](../topics/variables.md)
24
+
[Read more...](../fundamentals/variables.md)
25
25
26
26
## Values
27
27
28
28
Values are the "things" that you assign to a variable. All values have a type. In our example above, the variable `x` is assigned a value of type `number`. JavaScript supports the following types:
29
29
30
-
[Read more...](../topics/values.md)
30
+
[Read more...](../fundamentals/values.md)
31
31
32
32
## Operators
33
33
@@ -37,4 +37,4 @@ Values are the "things" that you assign to a variable. All values have a type. I
Variables that are objects also contain a list of things, but instead of them being in some specific order, they can be assigned to words, called "keys". Instead of "elements" the things that are inside objects are called "properties".
60
-
61
-
62
-
```js
63
-
let obj = {name:'John', age:24};
64
-
```
65
-
66
-
This object has two properties: `name` and `age`. The "value" of the property `name` is the string `'John'`. The "value" of the property `age` is the number `24`.
67
-
68
-
When accessing object properties, you can use the dot-notation: `obj.name` or the bracket-notation: `obj["name"]`. Note that the latter looks a lot like the way to access array elements. However, here what's inside the bracket (called "key" for objects, instead of "index") must be a string.
69
-
70
-
```js
71
-
console.log(obj.name); // -> 'John'
72
-
console.log(obj['name']); // -> 'John'
73
-
```
74
-
75
-
Just like with arrays, you can also use a variable to access properties, as long as these variables are strings. In this case you cannot use the dot-notation!
76
-
77
-
```js
78
-
var ageKey ='age';
79
-
console.log(obj[ageKey]); // -> 24
80
-
```
81
-
82
-
Remember that there is a very big difference between `obj[name]` and `obj["name"]`.
83
-
84
-
> Note:
85
-
>
86
-
> Thinking back of arrays, the length of an array can be retrieved by `arr.length`. So as mentioned before, arrays are just like other JavaScript objects. You could even write `arr['length']` to access the `length` property of the array. JavaScript will look: is what we put between brackets a number? Then it is an index and we'll look up the correct array element. If it's a string, it's a key and we will look up the corresponding property.
87
-
31
+
[Read more...]((../fundamentals/object.md)
88
32
89
33
## Functions
90
34
91
35
A function is a reusable piece of code. Functions are *very* important in JavaScript, to the extent that some people call JavaScript a "function-oriented" language. As mentioned above, variables can be of type function. In fact, *every function is a variable*.
92
36
93
-
The following two pieces of code have the exact same result:
94
-
95
-
```js
96
-
functionsum(a, b) {
97
-
return a + b;
98
-
}
99
-
```
100
-
101
-
and
102
-
103
-
```js
104
-
letsum=function (a, b) {
105
-
return a + b;
106
-
}
107
-
```
108
-
109
-
> Note
110
-
>
111
-
> This is not entirely true, as in the second code, the function is "anonymous", i.e. it has no name. But in both cases, you can call the function like this: `sum(4, 5)`.
112
-
113
-
### Parameters & arguments
114
-
115
-
When writing `function sum(a, b)`, `a` and `b` are the "parameters" of the function. We say that this function has two parameters. (Sometimes, you'll see the word "arity": this function has "arity" 2, but that is something you don't have to use for now.)
116
-
117
-
Now, when *calling* function sum, e.g. `var s = sum(4, 5);`, we say that the numbers `4` and `5` are the "arguments" of the function. Arguments are "passed" to the function: "we pass `4` and `5` to the function `sum`".
118
-
119
-
So remember the difference between the word "parameter" and "argument". Many people confuse them, and that's not a big problem, but understanding the difference is always nice:
120
-
121
-
* A parameter is the name you want to give to the variable that is available inside of the function.
122
-
* An argument is the actual value you want to assign to the parameters when you call the function.
123
-
124
-
A function that "has two parameters" is also said to "take/accept two arguments". But, sometimes you'll hear people say: "the function has two arguments" or "the function takes two parameters". While formally incorrect, you'll know what they mean.
125
-
126
-
### Calling a function on something
127
-
128
-
In JavaScript, you can call functions *on* something. By this, we mean that you use the dot to call the function. For instance, when we say "call method `trim` on string `s`", we mean:
129
-
130
-
```js
131
-
let s =" this is a string ";
132
-
s.trim(); // -> "this is a string"
133
-
```
134
-
135
-
> Note
136
-
>
137
-
> Technically, this means that the string `s` will become the `this` special variable inside of the function.
138
-
139
-
However, there are functions that you don't call on anything:
140
-
141
-
```js
142
-
functionsum(a, b) { return a + b; }
143
-
sum(4, 5); // -> 9
144
-
```
145
-
146
-
Here, you call the function `sum` on nothing.
147
-
148
-
Most built-in functions in JavaScript, like math functions or logging functions, also use the dot:
149
-
150
-
```js
151
-
Math.round(4.5);
152
-
console.log("hello");
153
-
Array.from([1, 2, 3]);
154
-
```
155
-
156
-
Indeed, these functions are also called "on" `Math`, `console`, `Array`, and so on. However, in this case, their purpose is more to group them logically, so here it's not very important to use that terminology. We'd rather say: "call the function `Math.round` with `4.5` as an argument", i.e. we include it in the full name of the methods.
157
-
158
-
It's more when you think about which functions you can call "on" your own variables (strings, arrays, numbers, etc):
159
-
160
-
```js
161
-
myString.trim();
162
-
myArray.slice();
163
-
myNumber.toString();
164
-
...
165
-
```
166
-
37
+
[Read more...]((../fundamentals/functions.md)
167
38
168
39
## Statements & expressions
169
40
170
41
Most programming languages that you'll encounter in real life are called "imperative" programming languages. JavaScript is such an imperative programming language. Imperative is another word for command-like. That is, you give the computer a bunch of commands after each other. First do this, then do that, etc.
171
42
172
-
These individual commands are called "statements" in imperative programming languages. You can compare them with sentences in the English language. They have a use by themselves, and do not need something else. "The man eats bread." is a full sentence, it conveys a meaning by itself. A sentence in English is always terminated by a period.
173
-
174
-
Similarly, a statement in JavaScript should provide a command by itself. JavaScript-statements are (almost always) terminated by a semicolon.
175
-
176
-
This is a complete statement:
177
-
178
-
```js
179
-
let s ="HackYourFuture";
180
-
```
181
-
182
-
It is a full command: declare a variable `s` and initialize it with `"HackYourFuture"`. JavaScript doesn't need any other information to know what we want. The statement is terminated with a semicolon.
183
-
184
-
However, this is not a complete statement:
185
-
186
-
```js
187
-
4+5
188
-
```
189
-
190
-
This equals `9`, but what is JavaScript to do with it? It doesn't provide a command. You'd need to do something with it, e.g. `var x = 4 + 5;` or `callFunction(4 + 5)`. We call these parts of statements "expressions". Expressions are not terminated by semicolons. Expressions always "evaluate into a value". In our example, the expression `4 + 5` "evaluates into `9`". If expressions cannot be evaluated into a value, they are invalid. For instance, `4 +` is not a valid expression, it is incomplete, because we need something else after the plus sign.
191
-
192
-
So, statements can *contain* expressions. Can expressions contain statements? No, they cannot. However, they can themselves contain expressions. Think about `4 + 5`: it contains the expressions `4` and `5`, as these both evaluate into a value: the expression `4` evaluates into the number `4`, it is a very simple expression. Similarly, `true`, `null`, `undefined` are all expressions.
193
-
194
-
### Examples of expressions
195
-
196
-
Here are some examples of expressions. Remember: expressions evaluate into a value, but do not provide a command:
197
-
198
-
*`sum(a, b)`
199
-
*`a`
200
-
*`a > 4 ? "yes" : "no"`
201
-
*`a + b`
202
-
*`a && b || c`
203
-
*`arr.length`
204
-
*`obj["name"]`
205
-
*`[1, 2, 3]`
206
-
*`arr[1]`
207
-
*`[1]` (this is an array with one element!)
208
-
*`function a() { return 4; }`
209
-
210
-
The last one requires a bit of explanation. If you write:
211
-
212
-
```js
213
-
functiona() { return4; }
214
-
```
215
-
216
-
by itself, this is a *statement* (a function declaration statement). However, if you write it as part of a statement, such as:
217
-
218
-
```js
219
-
letb=functiona() { return4; }
220
-
```
221
-
222
-
now it is an expression. This is an exceptional situation where something can be a statement or an expression.
A function is a reusable piece of code. Functions are *very* important in JavaScript, to the extent that some people call JavaScript a "function-oriented" language. As mentioned above, variables can be of type function. In fact, *every function is a variable*.
4
+
5
+
The following two pieces of code have the exact same result:
6
+
7
+
```js
8
+
functionsum(a, b) {
9
+
return a + b;
10
+
}
11
+
```
12
+
13
+
and
14
+
15
+
```js
16
+
letsum=function (a, b) {
17
+
return a + b;
18
+
}
19
+
```
20
+
21
+
> Note
22
+
>
23
+
> This is not entirely true, as in the second code, the function is "anonymous", i.e. it has no name. But in both cases, you can call the function like this: `sum(4, 5)`.
24
+
25
+
## Parameters & arguments
26
+
27
+
When writing `function sum(a, b)`, `a` and `b` are the "parameters" of the function. We say that this function has two parameters. (Sometimes, you'll see the word "arity": this function has "arity" 2, but that is something you don't have to use for now.)
28
+
29
+
Now, when *calling* function sum, e.g. `var s = sum(4, 5);`, we say that the numbers `4` and `5` are the "arguments" of the function. Arguments are "passed" to the function: "we pass `4` and `5` to the function `sum`".
30
+
31
+
So remember the difference between the word "parameter" and "argument". Many people confuse them, and that's not a big problem, but understanding the difference is always nice:
32
+
33
+
* A parameter is the name you want to give to the variable that is available inside of the function.
34
+
* An argument is the actual value you want to assign to the parameters when you call the function.
35
+
36
+
A function that "has two parameters" is also said to "take/accept two arguments". But, sometimes you'll hear people say: "the function has two arguments" or "the function takes two parameters". While formally incorrect, you'll know what they mean.
37
+
38
+
## Calling a function on something
39
+
40
+
In JavaScript, you can call functions *on* something. By this, we mean that you use the dot to call the function. For instance, when we say "call method `trim` on string `s`", we mean:
41
+
42
+
```js
43
+
let s =" this is a string ";
44
+
s.trim(); // -> "this is a string"
45
+
```
46
+
47
+
> Note
48
+
>
49
+
> Technically, this means that the string `s` will become the `this` special variable inside of the function.
50
+
51
+
However, there are functions that you don't call on anything:
52
+
53
+
```js
54
+
functionsum(a, b) { return a + b; }
55
+
sum(4, 5); // -> 9
56
+
```
57
+
58
+
Here, you call the function `sum` on nothing.
59
+
60
+
Most built-in functions in JavaScript, like math functions or logging functions, also use the dot:
61
+
62
+
```js
63
+
Math.round(4.5);
64
+
console.log("hello");
65
+
Array.from([1, 2, 3]);
66
+
```
67
+
68
+
Indeed, these functions are also called "on" `Math`, `console`, `Array`, and so on. However, in this case, their purpose is more to group them logically, so here it's not very important to use that terminology. We'd rather say: "call the function `Math.round` with `4.5` as an argument", i.e. we include it in the full name of the methods.
69
+
70
+
It's more when you think about which functions you can call "on" your own variables (strings, arrays, numbers, etc):
Variables that are objects also contain a list of things, but instead of them being in some specific order, they can be assigned to words, called "keys". Instead of "elements" the things that are inside objects are called "properties".
4
+
5
+
6
+
```js
7
+
let obj = {name:'John', age:24};
8
+
```
9
+
10
+
This object has two properties: `name` and `age`. The "value" of the property `name` is the string `'John'`. The "value" of the property `age` is the number `24`.
11
+
12
+
When accessing object properties, you can use the dot-notation: `obj.name` or the bracket-notation: `obj["name"]`. Note that the latter looks a lot like the way to access array elements. However, here what's inside the bracket (called "key" for objects, instead of "index") must be a string.
13
+
14
+
```js
15
+
console.log(obj.name); // -> 'John'
16
+
console.log(obj['name']); // -> 'John'
17
+
```
18
+
19
+
Just like with arrays, you can also use a variable to access properties, as long as these variables are strings. In this case you cannot use the dot-notation!
20
+
21
+
```js
22
+
var ageKey ='age';
23
+
console.log(obj[ageKey]); // -> 24
24
+
```
25
+
26
+
Remember that there is a very big difference between `obj[name]` and `obj["name"]`.
27
+
28
+
> Note:
29
+
>
30
+
> Thinking back of arrays, the length of an array can be retrieved by `arr.length`. So as mentioned before, arrays are just like other JavaScript objects. You could even write `arr['length']` to access the `length` property of the array. JavaScript will look: is what we put between brackets a number? Then it is an index and we'll look up the correct array element. If it's a string, it's a key and we will look up the corresponding property.
0 commit comments