Check if array is 2D
$ npm install --save is-2d-array
const is2dArray = require('is-2d-array');
is2dArray([['1', '2'], ['3', '4']]);
//=> true
is2dArray(['1', '2', '3', '4']);
//=> false
is2dArray([['1', '2'], '3', '4']);
//=> false
is2dArray([['1'], ['2'], ['3'], ['4']]);
//=> true
Returns an boolean
based on if it's a true 2D array or not.
MIT © Lukasz Brodowski