minstache icon indicating copy to clipboard operation
minstache copied to clipboard

Strong array check is not needed

Open jmas opened this issue 10 years ago • 0 comments

I think we do not need strong array check at function:

function section(obj, prop, negate, thunk) {
  var val = obj[prop];
  if (Array.isArray(val)) return val.map(thunk).join('');
  if ('function' == typeof val) return val.call(obj, thunk(obj));
  if (negate) val = !val;
  if (val) return thunk(obj);
  return '';
}

I explain why. I have array-like object (extended from Array). And minstache do not understand that array-like object have Array as prototype.

I propose to change Array.isArray(val) to val instanceof Array.

And when we using Array.isArray(val) we forgot about IE8.

Thanks.

jmas avatar Sep 25 '14 00:09 jmas