jashkenas / jashkenas/coffeescript
Proposal: Document Existential Operator Assignment
- Dominant language
- CoffeeScript
- Stars
- 16.6k
- Forks
- 2k
- PR merge metrics
- No merged PRs in 30d
Description
In a divergence from the way [optional chaining](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining) works in JS, CoffeeScript allows the existential operator on the left half of an assignment, whereas as JS [does not](https://github.com/tc39/proposal-optional-chaining#not-supported).
You can see an example of this in the [following code](https://coffeescript.org/#try:el%20%3D%20document.getElementById(%22a%22)%0A%0Ael%3F.href%20%3D%20%22b%22):
```js
// input
el?.href = "b"
// output
if (el != null) {
el.href = "b";
}
```
However, I don't see this documented anyway in the [Existential Operator](https://coffeescript.org/#existential-operator) section in the docs
Since it's different from the EcmaScript implementation, it might be helpful to officially list in in CoffeeScripts docs.
Contributor guide
Research direction
Start with the Existential Operator section in the CoffeeScript documentation and compare it with the linked example. Document that CoffeeScript permits existential-operator assignment on the left side, including the example output and its difference from JavaScript optional chaining.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- coffeescript
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 52/100