Correctness of a CSV writer in Node.js
There's a few points you can improve on:



throw:


throw "Object is not an Array";



You should use throw new Error instead of throw as throw new Error contains a stack trace as well.



for in:

for in is a bit weird and can cause issues as it iterates over prototypes as well.

Considering you're testing that the properties are array items anyway, you can just use forEach instead.


if(ob instanceof Array){
    for(r in ob){
        if(ob.hasOwnProperty(r)){
            row = ob[r];



into:

if(ob instanceof Array){
    ob.forEach(function(row, index){
        //...




Declaring globals:

You shouldn't be declaring globals like:


var str = "", row, a, i, o, c, r;



Use them at their respective levels, don't have left over variables.