result from `parse` no longer has `hasOwnProperty` method
See original GitHub issuein 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:
- Created 8 years ago
- Comments:18 (4 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I reverted that change and did a patch release. Sorry for the trouble. I didn’t realize users were dependent on the behavior…
You’re right, but a lot of people write it as
obj.hasOwnProperty
instead of going up toObject.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.