Reputation: 547
Question is very Simple. If you instance, for example, a Buffer you do:
b = new Buffer(0);
then you check the type:
typeof b;
The result is 'Object', but I want to know it is a Buffer.
If you made this in the node console you get it:
>b = new Buffer(1024);
>typeof b
'object'
> b
<Buffer ...>
So, some how the console knows that b is a Buffer.
Upvotes: 6
Views: 20267
Reputation: 39518
In your case:
b = new Buffer(1024);
if (b instanceof Buffer) {
...
More generally, see this answer.
Upvotes: 11