Use what works for you, and don't bother with premature optimization.

By the way it's not greatest bind use case, I wouldn't use bind here. In 
some older versions of node (v0.6.3 ?) , setTimeout passes one argument to 
the callback, and in your example it will be logged as well.


On Tuesday, May 29, 2012 2:52:46 AM UTC+2, phidelta wrote:
>
> Hi all, 
>
> I have recently come to use .bind a lot, because it makes for very 
> clean code. 
>
> So rather than doing 
>
> <code> 
> var x; // this has some value that comes from prior code 
> setTimeout(function() { console.log(x) }, 5000); 
> </code> 
>
> I am now often doing 
>
> <code> 
> var x; 
> setTimeout(console.log.bind(console, x), 5000); 
> </code> 
>
> The question I have is: what is more performant? Is there any reason 
> to avoid .bind()? 
>
> Regards, Phil

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to