Documentation improvement: clarify function assignment behavior

Aperta Adatta ai principianti
#3,973 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
72/100
Tipo di issue
Documentazione
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
javascript
Ambito
documentation

Direzione di ricerca

Apri la sezione Function expressions all’indirizzo https://javascript.info/function-expressions e individua l’argomento “Function is a Value” e il relativo esempio di assegnazione. Rivedi la formulazione intorno a “copy a function” e chiarisci che viene assegnato il riferimento allo stesso oggetto funzione, mantenendo il comportamento dell’esempio. Il lavoro è concluso quando la spiegazione è inequivocabile per chi sta imparando e l’esempio rimane corretto.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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

Lingua principale
HTML
Stelle
25.5k
Fork
4k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di javascript-tutorial/en.javascript.info

Tutte le issue di javascript-tutorial/en.javascript.info

Issue simili

Altre issue su Documentation

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.