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

Partial Application without bind (simpler solution) #36

Closed
edwardbc opened this issue Dec 8, 2013 · 2 comments
Closed

Partial Application without bind (simpler solution) #36

edwardbc opened this issue Dec 8, 2013 · 2 comments

Comments

@edwardbc
Copy link

edwardbc commented Dec 8, 2013

Given the little understanding an user might have of the apply/call handling I think that the provided solution might be confusing. I would switch from :

var slice = Array.prototype.slice

  function logger(namespace) {
    return function() {
      console.log.apply(console, [namespace].concat(slice.call(arguments)))
    }
  }

  module.exports = logger

to something simpler like

var slice = Array.prototype.slice;

function logger(namespace) {
  return function(){
    console.log(namespace, slice.call(arguments).join(' ') );
  }
}

 module.exports = logger;

Any thoughts?

@timoxley
Copy link
Owner

timoxley commented Jan 3, 2014

@edwardbc whoa, sorry I missed this issue. The whole purpose of this exercise is to encourage people to use apply to implement partial application. I will work on the text to make things more clear.

@edwardbc
Copy link
Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants