Metadata
- Source
- FLUID-5826
- Type
- Bug
- Priority
- Major
- Status
- Closed
- Resolution
- Not A Bug
- Assignee
- Antranig Basman
- Reporter
- Kasper Galschiot Markus
- Created
2015-12-09T04:39:53.688-0500 - Updated
2024-07-22T09:30:49.934-0400 - Versions
- N/A
- Fixed Versions
- N/A
- Component
-
- Framework
Description
The fluid.copy function does not copy keys (and values) for which the value is undefined. For example:
fluid.copy({ a: "hello world", b: undefined})
Will return the following object:
{ a: "hello world" }
Whereas an exact copy obviously would be:
{ a: "hello world", b: undefined}
@@Antranig Basman is this a design decision or a bug?
Comments
-
Antranig Basman commented
2015-12-09T08:30:51.669-0500 It's a design decision. Objects with "undefined" values are unnatural and invalid for interchange, and should not be used. fluid.copy is consistent with the wider body of algorithms which operate on JSON-like values such as $.extend, fluid.transform, etc. It's a widespread idiom (or axiom) within JavaScript that a standard means of cloning an object should be to convert it to JSON and then re-parse it - in fact in many environments such as CouchDB this is the only standard means provided.
-
Kasper Galschiot Markus commented
2015-12-09T08:35:27.238-0500 Awesome! Thanks for clearing that up, @@Antranig Basman