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

Use Object.prototype.hasOwnProperty instead of using hasOwnProperty directly #107

Merged
merged 3 commits into from
Sep 4, 2013

Conversation

wanderer
Copy link
Contributor

@wanderer wanderer commented Sep 4, 2013

Node's QueryString lib can and will give us objects that do not have or override hasOwnProperty. See here When that happens waterline will crash. This PR fixes that.

wanderer added 3 commits September 1, 2013 00:17
fix a spelling error I made and did a little bit of cleanup
@wanderer
Copy link
Contributor Author

wanderer commented Sep 4, 2013

also cleaned up a spelling error I made in the docs

@joonhocho
Copy link
Contributor

what kind of library overrides hasOwnProperty and why?
And why is the code double checking hasOwnProperty in the first place anyway?
Object.keys(obj) already gives you all enumerable properties that are owned by an object.
Unless the obj itself is modified during the callback, it shouldn't be necessary.

@joonhocho
Copy link
Contributor

Oh, I see "delete obj[property]". That is why it is double checking.

particlebanana added a commit that referenced this pull request Sep 4, 2013
Use Object.prototype.hasOwnProperty instead of using hasOwnProperty directly
@particlebanana particlebanana merged commit b64d840 into balderdashy:master Sep 4, 2013
@wanderer
Copy link
Contributor Author

wanderer commented Sep 4, 2013

@joonho1101 one reason you would might want override hasOwnProperty in a library is when you are dealing with hashes of raw data. For example query strings. what would happen with you wanted to parse a url like www.test.com/?hasOwnProperty=nope into an object?

@joonhocho
Copy link
Contributor

I see it now. Good example. Thanks :)

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

Successfully merging this pull request may close these issues.

3 participants