Re: [whatwg/fetch] Behavior of `Headers.set(name, null)` and `Headers.get(name)` (Issue #1792)

> I think `set()` performing `delete()` would also be quite unexpected. JavaScript's `Map` indeed forces one to use `has()` or to avoid using undefined as a value, but that makes sense for a general collection type.

TBF, for headers and attributes, it would have made more sense to use `undefined` instead of `null`.
Setting as `undefined` then meaning an absence of value. Though this is true that `a.foo = undefined` isn't equivalent to `delete a.foo` in JS.

Maybe the best way would have been to have `get(name, default_value)`, which, if not given (i.e. `args.length < 2`), raises an exception. Then the `set`/`get` symmetry would be respected.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/fetch/issues/1792#issuecomment-2527175098
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/fetch/issues/1792/2527175098@github.com>

Received on Monday, 9 December 2024 07:48:37 UTC