javascript-tutorial / javascript-tutorial/en.javascript.info
Documentation improvement: clarify function assignment behavior
Personne n'a encore pris cette issue.
- Langage dominant
- HTML
- Étoiles
- 25.5k
- Forks
- 4k
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Description
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
Guide de contribution
Aucun guide de contribution indexé pour ce dépôt
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Ouvrez la section Function expressions à l’adresse https://javascript.info/function-expressions et trouvez le thème « Function is a Value » ainsi que son exemple d’affectation. Examinez la formulation autour de « copy a function » et précisez que c’est une référence vers le même objet fonction qui est affectée, tout en préservant le comportement de l’exemple. C’est terminé lorsque l’explication est dépourvue d’ambiguïté pour les personnes qui apprennent et que l’exemple reste correct.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- javascript
- Domaine
- documentation
- Type d'issue
- Documentation
- Difficulté
- 2/5
- Temps estimé
- 1-3 heures
- Activité
- Calme
- Clarté
- Plutôt claire
- Accessibilité débutants
- 72/100