-
Notifications
You must be signed in to change notification settings - Fork 30
Function expressions #93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For future reference - please don't replace the colons with brackets, don't add extra bold, emoji, etc. This may change the context of the original text :)
|
||
In JavaScript, a function is not a "magical language structure", but a special kind of value. | ||
W JavaScripcie, funkcje nie są "magicznymi konstrukcjami językowymi", lecz po prostu rodzajem wartości. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please replace lecz po prostu rodzajem wartości
by lecz szczególnym rodzajem wartości
- it shouldn't change the context of the original sentence :)
}; | ||
``` | ||
|
||
Here, the function is created and assigned to the variable explicitly, like any other value. No matter how the function is defined, it's just a value stored in the variable `sayHi`. | ||
Funkcja jest tworzona i przypisywana do zmiennej - tak, jakby była to zwykła wartość. Nie ważne, w jaki sposób zostanie ona zdefiniowana - będzie to po prostu wartość, przechowywana w zmiennej `sayHi`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You skipped the word explicitly
. Pleace change: Funkcja jest tworzona i przypisywana do zmiennej
to Funkcja jest tworzona i jawnie przypisywana do zmiennej
.
|
||
Let's look at more examples of passing functions as values and using function expressions. | ||
Spójrzmy na kolejne przykład przekazywania funkcji jako wartości oraz wykorzystania wyrażeń funkcyjnych. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo! Please replace przykład
by przykłady
- plural form :)
@@ -121,24 +121,24 @@ function ask(question, yes, no) { | |||
*/!* | |||
|
|||
function showOk() { | |||
alert( "You agreed." ); | |||
alert( "Może być." ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please replace Może być
by Zgoda została wyrażona
. I thought about Zgodziłeś się
but then the expression does not have a female version. Any other ideas?
} | ||
|
||
function showCancel() { | ||
alert( "You canceled the execution." ); | ||
alert( "Nie chcesz nic wywoływać." ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please replace Nie chcesz nic wywoływać
by Wykonanie zostało anulowane
.
let sum = function(a, b) { | ||
return a + b; | ||
}; | ||
``` | ||
|
||
The more subtle difference is *when* a function is created by the JavaScript engine. | ||
Bardziej subtelną różnicą jest różnica w *momencie tworzenia* funkcji przez silnik JavaScriptu. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pleace replace Bardziej subtelną różnicą jest różnica w *momencie tworzenia* funkcji przez silnik JavaScriptu.
by Bardziej subtelną różnicą jest to *kiedy* funkcja jest tworzona przez silnik JavaScriptu.
|
||
That's due to internal algorithms. When JavaScript prepares to run the script, it first looks for global Function Declarations in it and creates the functions. We can think of it as an "initialization stage". | ||
Wynika to z algorytmu wykonywania skryptu. Przygotowując skrypt do wykonania, JavaScript najpierw wyszukuje w nim globalnych deklaracji funkcji, a następnie je tworzy - można nazwać to etapem "inicjalizacji". |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace Wynika to z algorytmu wykonywania skryptu.
by Wynika to z wewnętrznego algorytmu wykonywania skryptu.
@@ -294,75 +294,75 @@ if (age < 18) { | |||
} | |||
} | |||
|
|||
// Here we're out of curly braces, | |||
// so we can not see Function Declarations made inside of them. | |||
// Skończyły nam się klamerki, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
klamerki
may be confusing. Pleace replace it by nawiasy klamrowe
.
|
||
...But if a Function Declaration does not suit us for some reason, or we need a conditional declaration (we've just seen an example), then Function Expression should be used. | ||
Dopiero jeśli z jakichś powodów deklaracja funkcji nie odpowiada naszym potrzebom (kiedy, jak w przykładzie, potrzebujemy warunkowej deklaracji funkcji), wtedy można rozważyć użycie wyrażenia funkcyjnego. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pleace replace
Dopiero jeśli z jakichś powodów deklaracja funkcji nie odpowiada naszym potrzebom (kiedy, jak w przykładzie, potrzebujemy warunkowej deklaracji funkcji)
by
Dopiero jeśli z jakichś powodów deklaracja funkcji nie odpowiada naszym potrzebom, albo potrzebujemy warunkowej deklaracji funkcji (jak w przykładzie powyżej)
- I think it is more meaningful :)
|
||
...But if a Function Declaration does not suit us for some reason, or we need a conditional declaration (we've just seen an example), then Function Expression should be used. | ||
Dopiero jeśli z jakichś powodów deklaracja funkcji nie odpowiada naszym potrzebom (kiedy, jak w przykładzie, potrzebujemy warunkowej deklaracji funkcji), wtedy można rozważyć użycie wyrażenia funkcyjnego. | ||
``` | ||
|
||
## Summary |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace Summary
by Podsumowanie
:)
Please make the requested changes. After it, add a comment "/done". |
Translated the article into Polish.