Why are null and undefined variables removed from params
See original GitHub issueI would expect
let a
let b
axios({ params: { a, b })
To construct ?a=&b=
Issue Analytics
- State:
- Created 6 years ago
- Reactions:7
- Comments:35 (4 by maintainers)
Top Results From Across the Web
What is the difference between null and undefined in ...
so basically null value means a variable has been explicitly set as (no value = null) or has been initialized and defined to...
Read more >jQuery.param outputs "null" and "undefined" in the query string
null and undefined are perfectly acceptable values for input data. Their meaning is quite obviously: "in the structure, yet empty"... and the only...
Read more >Difference between null and undefined in JavaScript
A null means the absence of a value. You assign a null to a variable with the intention that currently this variable does...
Read more >NULL - Manual - PHP
Casting a variable to null using (unset) $var will not remove the variable or unset its value. It will only return a null...
Read more >null - JavaScript - MDN Web Docs - Mozilla
null is not an identifier for a property of the global object, like undefined can be. Instead, null expresses a lack of identification,...
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 Free
Top 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
All of these are possible:
{ key: undefined }
to?
(not included){ key: null }
to?key
{ key: '' }
to?key=
{ key: 'null' }
to?key=null
The current behavior is actually in line with how JSON values are handled in JavaScript:
JSON.stringify({ a:1, b:undefined, c:2 })
produces{"a":1,"c":2}
{a: undefined} is often used as a construct to ignore a JSON key. If you need “a=” then ‘’ seems to be semantically good enough.
Maybe {a: null} should be interpreted as “?a” param? But not undefined.