javascript-tutorial / javascript-tutorial/en.javascript.info

Documentation improvement: clarify function assignment behavior

Abierto Apto para principiantes
#3,973 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Lenguaje dominante
HTML
Estrellas
25.5k
Forks
4k
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

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

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Abre la sección Function expressions en https://javascript.info/function-expressions y localiza el tema “Function is a Value” y su ejemplo de asignación. Revisa la redacción en torno a “copy a function” y aclara que se asigna una referencia al mismo objeto función, manteniendo el comportamiento del ejemplo. Se considera terminado cuando la explicación no deja lugar a ambigüedades para quienes están aprendiendo y el ejemplo sigue siendo correcto.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
javascript
Área
documentation
Tipo de issue
Documentación
Dificultad
2/5
Tiempo estimado
1-3 horas
Estado de actividad
Tranquilo
Claridad
Bastante claro
Aptitud para principiantes
72/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.