question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

result from `parse` no longer has `hasOwnProperty` method

See original GitHub issue

in 3.0.1, parse had the following behavior:

> qs.parse('my-param=my-val')
{ 'my-param': 'my-val' }
> qs.parse('my-param=my-val').hasOwnProperty
[Function: hasOwnProperty]
> qs.parse('h=j').hasOwnProperty
[Function: hasOwnProperty]
> qs.parse('').hasOwnProperty
[Function: hasOwnProperty]

in 3.0.2, the object returned no longer has the hasOwnProperty method:

> qs.parse('hbud-fixture=not-logged-in')
{ 'hbud-fixture': 'not-logged-in' }
> qs.parse('hbud-fixture=not-logged-in').hasOwnProperty
undefined
> qs.parse('hbudfixture=not-logged-in').hasOwnProperty
undefined
> qs.parse('hbudfixture=notloggedin').hasOwnProperty
undefined
> qs.parse('').hasOwnProperty
[Function: hasOwnProperty]
> qs.parse('h=j').hasOwnProperty
undefined

I am unsure whether this was considered part of the API, but some consumers rely on the behavior - https://github.com/mjackson/history/blob/master/modules/useQueries.js#L13

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:18 (4 by maintainers)

github_iconTop GitHub Comments

5reactions
sindresorhuscommented, Mar 19, 2016

I reverted that change and did a patch release. Sorry for the trouble. I didn’t realize users were dependent on the behavior…

5reactions
taioncommented, Mar 18, 2016

You’re right, but a lot of people write it as obj.hasOwnProperty instead of going up to Object.prototype.hasOwnProperty. It’s a pretty big usability caveat.

Either way, though, this change in practice triggers enough bugs in consumers of this code that it should be released as breaking.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Object.prototype.hasOwnProperty() - JavaScript | MDN
The method returns false if the property is inherited, or has not been declared at all.
Read more >
hasOwnProperty is not a function in Node.js? - Stack Overflow
A way around the error is to call hasOwnProperty on Object explicitly, and bind it to the object, like so: // Calls "hasOwnProperty"...
Read more >
no-prototype-builtins - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >
json-safe-parse: Documentation | Openbase
JSON Safe Parse. Parse JSON and silently ignore or error on reserved keys like hasOwnProperty, toString, etc. Installation. npm install json-safe-parse ...
Read more >
Assertions — Postman Quick Reference Guide Version 1.9.0
In order to make the code more readable, we will create a function for that: ... function () { // Parse JSON body...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found