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

I don't understand the meaning of this sentence. #2016

Closed
booles opened this issue Jan 23, 2015 · 3 comments
Closed

I don't understand the meaning of this sentence. #2016

booles opened this issue Jan 23, 2015 · 3 comments
Labels

Comments

@booles
Copy link

booles commented Jan 23, 2015

_.each(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(name) {
    var method = ArrayProto[name];
    _.prototype[name] = function() {
      var obj = this._wrapped;
      method.apply(obj, arguments);
      if ((name === 'shift' || name === 'splice') && obj.length === 0) delete obj[0];
      return result.call(this, obj);
    };
  });

Why use this sentence? delete obj[0];???

if ((name === 'shift' || name === 'splice') && obj.length === 0) delete obj[0];

Please tell me! thanks!

@michaelficarra
Copy link
Collaborator

You might want to try deleting it and see which tests break.

@megawac
Copy link
Collaborator

megawac commented Jan 23, 2015

See #397 and #1807. You won't notice tests breaking unless you're on IE8. This line could probably do with a comment in the source (feel free to pr one)

@booles
Copy link
Author

booles commented Jan 23, 2015

@michaelficarra @megawac Thanks!

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

No branches or pull requests

3 participants