Skip to content

Commit 98b9e51

Browse files
authored
Update
1 parent 4be695f commit 98b9e51

1 file changed

Lines changed: 0 additions & 51 deletions

File tree

1-js/02-first-steps/15-function-basics/article.md

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -170,21 +170,6 @@ showMessage(from, "Hello"); // *Ann*: Hello
170170
alert( from ); // Ann
171171
```
172172
173-
<<<<<<< HEAD
174-
=======
175-
When a value is passed as a function parameter, it's also called an *argument*.
176-
177-
In other words, to put these terms straight:
178-
179-
- A parameter is the variable listed inside the parentheses in the function declaration (it's a declaration time term).
180-
- An argument is the value that is passed to the function when it is called (it's a call time term).
181-
182-
We declare functions listing their parameters, then call them passing arguments.
183-
184-
In the example above, one might say: "the function `showMessage` is declared with two parameters, then called with two arguments: `from` and `"Hello"`".
185-
186-
>>>>>>> 291b5c05b99452cf8a0d32bd32426926dbcc0ce0
187-
188173
## Προκαθορισμένες τιμές
189174
190175
Εάν μια παράμετρος δεν παρέχεται, τότε η τιμή της γίνεται `undefined`.
@@ -222,43 +207,7 @@ function showMessage(from, text = anotherFunction()) {
222207
223208
Στο παραπάνω παράδειγμα, το `anotherFunction()` καλείται κάθε φορά που το `showMessage()` καλείται χωρίς την παράμετρο `text`.
224209
225-
<<<<<<< HEAD
226210
### Εναλλακτικοί προεπιλεγμένοι παράμετροι
227-
=======
228-
````smart header="Default parameters in old JavaScript code"
229-
Several years ago, JavaScript didn't support the syntax for default parameters. So people used other ways to specify them.
230-
231-
Nowadays, we can come across them in old scripts.
232-
233-
For example, an explicit check for `undefined`:
234-
235-
```js
236-
function showMessage(from, text) {
237-
*!*
238-
if (text === undefined) {
239-
text = 'no text given';
240-
}
241-
*/!*
242-
243-
alert( from + ": " + text );
244-
}
245-
```
246-
247-
...Or using the `||` operator:
248-
249-
```js
250-
function showMessage(from, text) {
251-
// If the value of text is falsy, assign the default value
252-
// this assumes that text == "" is the same as no text at all
253-
text = text || 'no text given';
254-
...
255-
}
256-
```
257-
````
258-
259-
260-
### Alternative default parameters
261-
>>>>>>> 291b5c05b99452cf8a0d32bd32426926dbcc0ce0
262211
263212
Μερικές φορές έχει νόημα να ορίσετε προεπιλεγμένες τιμές για παραμέτρους όχι στη δήλωση συνάρτησης, αλλά σε μεταγενέστερο στάδιο, κατά την εκτέλεση.
264213

0 commit comments

Comments
 (0)