Skip to content

Commit

Permalink
... is not an operator
Browse files Browse the repository at this point in the history
The `...` in function call syntax is not an operator. It's more of a punctuation supported in various places (function call, function definition, array/object definitions, destructuring syntax), but specific to those. It does not produce a value like actual operators do.

I'd appreciate it if we can avoid spreading (no pun intended) this misconception. 

While "spread argument" isn't an official term either, there is none (https://www.ecma-international.org/ecma-262/9.0/index.html#sec-argument-lists), it's probably the closest reasonable term.

Happy for alternative suggestions though, or to hear the reasons why this shouldn't be corrected.
  • Loading branch information
fkling committed Jan 2, 2019
1 parent 258b654 commit 7c9470c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions docs/rules/prefer-spread.md
@@ -1,4 +1,4 @@
# Suggest using the spread operator instead of `.apply()`. (prefer-spread)
# Suggest using a spread argument instead of `.apply()`. (prefer-spread)

Before ES2015, one must use `Function.prototype.apply()` to call variadic functions.

Expand All @@ -7,7 +7,7 @@ var args = [1, 2, 3, 4];
Math.max.apply(Math, args);
```

In ES2015, one can use the spread operator to call variadic functions.
In ES2015, one can use a spread argument to call variadic functions.

```js
/*eslint-env es6*/
Expand All @@ -18,7 +18,7 @@ Math.max(...args);

## Rule Details

This rule is aimed to flag usage of `Function.prototype.apply()` in situations where the spread operator could be used instead.
This rule is aimed to flag usage of `Function.prototype.apply()` in situations where a spread argument could be used instead.

## Examples

Expand All @@ -37,7 +37,7 @@ Examples of **correct** code for this rule:
```js
/*eslint prefer-spread: "error"*/

// Using the spread operator
// Using a spread argument
foo(...args);
obj.foo(...args);

Expand Down

0 comments on commit 7c9470c

Please sign in to comment.