Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The Rest Parameter example could be different #65

Closed
mohsen1 opened this issue Jun 2, 2014 · 2 comments
Closed

The Rest Parameter example could be different #65

mohsen1 opened this issue Jun 2, 2014 · 2 comments

Comments

@mohsen1
Copy link
Contributor

mohsen1 commented Jun 2, 2014

I would like to propose changing the Rest Parameter example function.

A function like underscore's pick is a perfect example in my opinion

function pick(object, ...keys){
   let result = Object.create(null);
   for(let i = 0; i < keys.length; i++){
      let key = keys[i];
      result[key] = object[key];
   } 
   return results
}

I think current example is not demonstrating a very good use case of the feature.

@rwaldron
Copy link
Contributor

rwaldron commented Jun 2, 2014

function pick(object, ...keys) {
   let result = Object.create(null);
   for (let key of keys) {
      result[key] = object[key];
   } 
   return result;
}

@nzakas
Copy link
Owner

nzakas commented Jun 3, 2014

I like it, thanks for the suggestion.

@nzakas nzakas closed this as completed in 9621022 Jul 2, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants