Skip to content

Commit 2158f94

Browse files
committed
Merge pull request nzakas#176 from DenisHomich/typos
Fixed typo. (Functions/Rest parameters)
2 parents ad25a8b + 383613c commit 2158f94

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

manuscript/02-Functions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ console.log(bookData.year); // 2015
126126

127127
This function mimics the `pick()` method from Underscore. The first argument is the object from which to copy properties and every other argument is the name of a property that should be copied on the result. There are couple of things to notice about this function. First, it's not at all obvious that the function is capable of handling more than one parameter. You could add in several more named parameters, but you would always fall short of indicating that this function can take any number of parameters. Second, because the first parameter is named and used directly, you have to start looking in the `arguments` object at index 1 instead of starting at index 0. Remembering to use the appropriate indices with `arguments` isn't necessarily difficult, but it's one more thing to keep track of. ECMAScript 6 introduces rest parameters to help with these issues.
128128

129-
Rest parameters are indicated by three dots (`...`) preceding a named parameter. That named parameter then becomes an `Array` containing the rest of the parameters (which is why these are called "rest" parameters). For example, `sum()` can be rewritten using rest parameters like this:
129+
Rest parameters are indicated by three dots (`...`) preceding a named parameter. That named parameter then becomes an `Array` containing the rest of the parameters (which is why these are called "rest" parameters). For example, `pick()` can be rewritten using rest parameters like this:
130130

131131
```js
132132
function pick(object, ...keys) {

0 commit comments

Comments
 (0)