Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strong array check is not needed #12

Open
jmas opened this issue Sep 25, 2014 · 0 comments
Open

Strong array check is not needed #12

jmas opened this issue Sep 25, 2014 · 0 comments

Comments

@jmas
Copy link

jmas commented Sep 25, 2014

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant