Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions proposal-template.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,29 @@
# ECMAScript proposal: @Name
# ECMAScript proposal: Operator Declaration
- [Motivation](#motivation)
- [High-level API](#high-level-api)
- [FAQ](#faq)

## Motivation

Proposal motivation
Sometimes operator usage are more declaraive way than function calls:

```js
const sumOfAges = [{ count: 1 }, { count: 2 }, { count: 3 }, { count: 4 }].reduce((a, b) => a.count + b.count);
```

I propose to make operator declaration and make operators as a first-class object inside language

## High-level API

```js
// example code
const (+) = (a, b) => {
if ('count' in a && 'count' in b) {
return a.count + b.count;
}
return super(a, b);
}

const sumOfAges = [{ count: 1 }, { count: 2 }, { count: 3 }, { count: 4 }].reduce(+);
```

### FAQ
Expand Down