Documentation improvement: clarify function assignment behavior

未關閉 適合新手
#3,973 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
2/5
預估耗時
1-3 小時
新手友好度
72/100
Issue 類型
文件
描述清晰度
基本清楚
活躍度
冷清
技術堆疊
javascript
領域
documentation

研究方向

開啟 https://javascript.info/function-expressions 中的 Function expressions 區段,找到「Function is a Value」主題及其指派範例。檢查「copy a function」周圍的措辭,並釐清指派的是對同一個函式物件的參照,同時維持範例的行為不變。當說明對學習者來說明確無歧義,且範例仍然正確時,即視為完成。

由索引模型根據 Issue 內容生成。

描述

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

主要語言
HTML
星號
25.5k
分支
4k
PR 合併指標
30 天內沒有已合併 PR

貢獻指南

這個儲存庫沒有索引到貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

javascript-tutorial/en.javascript.info 的其他 Issue

查看 javascript-tutorial/en.javascript.info 的全部 Issue

相似的 Issue

更多 Documentation Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。