Is there some native/lodash/underscore/etc method to check if an obj is an empty array? [] === []
returns false due to different obj references. I wrote a quick checker for it:
function isArrayOfLength(obj, length) {
var isArrayOfSpecifiedLength = false;
if(Array.isArray(obj)){
if(obj.length === length){
isArrayOfSpecifiedLength = true;
}
}
return isArrayOfSpecifiedLength;
}
but I don't want to clutter up production code if something better is available. Plunk if you want it for whatever reason. Note - I need to be able to check any var type - the method might get an obj or an int, so I can't just check length without verifying that it's an array.