javascript-tutorial / javascript-tutorial/en.javascript.info
Documentation improvement: clarify function assignment behavior
Ninguém assumiu esta issue ainda.
- Linguagem predominante
- HTML
- Estrelas
- 25.5k
- Forks
- 4k
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Descrição
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
Guia de contribuição
Nenhum guia de contribuição indexado para este repositório
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Direção de pesquisa
Abra a seção Function expressions em https://javascript.info/function-expressions e localize o tópico “Function is a Value” e seu exemplo de atribuição. Revise o texto em torno de “copy a function” e esclareça que uma referência ao mesmo objeto de função é atribuída, preservando o comportamento do exemplo. O trabalho estará concluído quando a explicação for inequívoca para quem está aprendendo e o exemplo continuar correto.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- javascript
- Domínio
- documentation
- Tipo de issue
- Documentação
- Dificuldade
- 2/5
- Tempo estimado
- 1-3 horas
- Status de atividade
- Pouca atividade
- Clareza
- Razoavelmente clara
- Facilidade para iniciantes
- 72/100