Documentation improvement: clarify function assignment behavior

Offen Anfängerfreundlich
#3,973 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
72/100
Issue-Typ
Dokumentation
Klarheit
Größtenteils klar
Aktivitätsstatus
Ruhig
Tech-Stack
javascript
Bereich
documentation

Rechercherichtung

Öffne den Abschnitt Function expressions unter https://javascript.info/function-expressions und suche das Thema „Function is a Value“ sowie dessen Zuweisungsbeispiel. Überprüfe die Formulierung rund um „copy a function“ und stelle klar, dass die Referenz auf dasselbe Funktionsobjekt zugewiesen wird, wobei das Verhalten des Beispiels erhalten bleibt. Als erledigt gilt die Aufgabe, wenn die Erklärung für Lernende eindeutig ist und das Beispiel weiterhin korrekt ist.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

I was reading the Function expressions section and noticed a wording choice that confused me a little.

The section mentions that we can "copy a function to another variable". Maybe the intention is to show that functions are values in JavaScript, the wording initially made me think that a new function was being created.

issue in the section -> url -> https://javascript.info/function-expressions
topic is "Function is a Value"

the example code was ->
function sayHi() { // (1) create
alert( "Hello" );
}

let func = sayHi; // (2) copy

func(); // Hello // (3) run the copy (it works)!
sayHi(); // Hello // this still works too (why wouldn't it)

My understanding is that func receives a reference to the same function object rather than creating an independent copy of the function itself.
There maybe a chance that i have misunderstood it , the copy could mean the reference is copied and a little context about reference would help even if it is included in the previous section.

This is not a major issue, but I thought a small clarification might help readers who are learning about values and references.

Thank you so much for the documentation

Vorherrschende Sprache
HTML
Sterne
25.5k
Forks
4k
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus javascript-tutorial/en.javascript.info

Alle Issues in javascript-tutorial/en.javascript.info

Ähnliche Issues

Weitere Issues zu Documentation

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.