javascript-tutorial / javascript-tutorial/en.javascript.info
Documentation improvement: clarify function assignment behavior
Nobody has claimed this yet.
- Dominant language
- HTML
- Stars
- 25.5k
- Forks
- 4k
- PR merge metrics
- No merged PRs in 30d
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
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Open the Function expressions section at https://javascript.info/function-expressions and locate the “Function is a Value” topic and its assignment example. Review the wording around “copy a function” and clarify that the reference to the same function object is assigned, while preserving the example’s behavior. Done means the explanation is unambiguous for learners and the example remains correct.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 72/100