Check if Express request data is array Check if Express request data is array express express

Check if Express request data is array


The typical way to do this in any JavaScript environment would be:

if ( req.body instanceof Array ) {    // do stuff}

But since you have the luxury of your JavaScript running inside of V8, you could also use the following without any issues:

if ( Array.isArray(req.body) ) {    // do stuff}

Just personal preference on which one you use.