ahh. okay - thanks - i've been using js all these years and only just realised that toString was the default method on an object. =)
On Feb 28, 11:57 pm, Marcel Laverdet <[email protected]> wrote: > There's nothing magic happening here, it's just the toString() method > behaving as normal: > > marcel@air ~ $ cat foo.js > var foo = {toString: function() { return 'foo' }}; > console.log(foo + foo); > > marcel@air ~ $ node foo.js > foofoo > > > > > > > > On Tue, Feb 28, 2012 at 1:56 PM, billywhizz <[email protected]> wrote: > > from some initial tests, it seems 20 be about 30% faster to do s = > > a.toString + b.toString() instead of s = a + b > > > On Feb 28, 11:41 pm, billywhizz <[email protected]> wrote: > > > I'm struggling to understand why the following works when > > > concatenating two buffers into strings: > > > > var a = new Buffer("0123456789"); > > > var b = new Buffer("0123456789"); > > > var s = a + b; > > > console.log(s); > > > > is the addition operator overloaded in some way to coerce a buffer > > > into a string when used with two buffers? if so, does it always do a > > > conversion to utf8 or ascii? is this a bad way of doing things > > > generally? > > > > thanks for any info. > > > -- > > 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 -- 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
