jashkenas / jashkenas/coffeescript

Proposal: Document Existential Operator Assignment

Open
#5,446 0 comments 4 reactions 0 assignees View on GitHub
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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.