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: 1-js/06-advanced-functions/06-function-object/article.md
+20-20Lines changed: 20 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,20 +1,20 @@
1
1
2
-
# Function object, NFE
2
+
# Obiectul funcției, NFE
3
3
4
-
As we already know, a function in JavaScript is a value.
4
+
După cum știm deja, o funcție în JavaScript este o valoare.
5
5
6
-
Every value in JavaScript has a type. What type is a function?
6
+
Fiecare valoare în JavaScript are un tip. Ce tip are o funcție?
7
7
8
-
In JavaScript, functions are objects.
8
+
În JavaScript, funcțiile sunt obiecte.
9
9
10
-
A good way to imagine functions is as callable "action objects". We can not only call them, but also treat them as objects: add/remove properties, pass by reference etc.
10
+
Un mod bun de a ne imagina funcțiile este ca "obiecte de acțiune" apelabile. Putem nu doar să le apelăm, ci și să le tratăm ca pe niște obiecte: să adăugăm/eliminăm proprietăți, să le transmitem prin referință etc.
11
11
12
12
13
-
## The "name" property
13
+
## Proprietatea "name"
14
14
15
-
Function objects contain some useable properties.
15
+
Obiectele funcție conțin câteva proprietăți utilizabile.
16
16
17
-
For instance, a function's name is accessible as the "name" property:
17
+
De exemplu, numele unei funcții este accesibil sub forma proprietății "name":
18
18
19
19
```js run
20
20
functionsayHi() {
@@ -24,29 +24,29 @@ function sayHi() {
24
24
alert(sayHi.name); // sayHi
25
25
```
26
26
27
-
What's kind of funny, the name-assigning logic is smart. It also assigns the correct name to a function even if it's created without one, and then immediately assigned:
27
+
Ceea ce este oarecum amuzant, logica de atribuire a numelui este inteligentă. De asemenea îi atribuie numele corect unei funcții chiar dacă aceasta este creată fără nume, și apoi este atribuită imediat:
28
28
29
29
```js run
30
30
letsayHi=function() {
31
-
alert("Hi");
31
+
alert("Salut");
32
32
};
33
33
34
-
alert(sayHi.name); // sayHi (there's a name!)
34
+
alert(sayHi.name); // sayHi (există un nume!)
35
35
```
36
36
37
-
It also works if the assignment is done via a default value:
37
+
De asemenea funcționează și în cazul în care atribuirea se face printr-o valoare implicită:
38
38
39
39
```js run
40
40
functionf(sayHi=function() {}) {
41
-
alert(sayHi.name); // sayHi (works!)
41
+
alert(sayHi.name); // sayHi (funcționează!)
42
42
}
43
43
44
44
f();
45
45
```
46
46
47
-
In the specification, this feature is called a "contextual name". If the function does not provide one, then in an assignment it is figured out from the context.
47
+
În specificație, această trăsătură se numește "nume contextual". Dacă funcția nu oferă unul, atunci acesta este dedus din context într-o atribuire.
0 commit comments