Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

node js buffer and var difference

node js buffer and var difference

Problem

while using Node js if I use

buf1= new Buffer(50);
and var buf='';

what is the Difference in this initialization. when should we use Buffer

Problem courtesy of: The Learner

Solution

It seems like you are rather confused about this, or just worded this question in a strange manner. In my experience, it's pretty rare that you'll want to use a buffer over something like a string unless you are dealing with streaming or low-level operations. It seems like the first variable you declared is a buffer, and the second one is a string. If you add a little more context, I'd be able to help you decide whether you need a buffer or a string.

In general, I think the docs on Buffer are what you're after: http://nodejs.org/api/buffer.html#buffer_buffer

Solution courtesy of: Jeff Escalante

Discussion

View additional discussion.



This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

node js buffer and var difference

×

Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription

×