_.has
Does the object have that key? _.has, and the dict gotcha
- py_dict
- BOOLEAN
_.has answers a yes/no question: does this object contain that key? The description says it's identical to Object.hasOwnProperty(key) - a safe, override-proof membership check. In the graph it gives you a BOOLEAN output, which is gold for feeding an IfElse-style branch node: "if the config has a seed key, do X, else Y."
It's one of the _.* nodes in sfinktah/comfy-ovum, the auto-generated wrappers around underscore3 (a Python port of Underscore.js). Display name _.has, class UnderscoreHas.
The inputs that matter
- py_dict - the object to check (loose
*; also accepts a_.CHAIN). Namedpy_dictto signal it expects a dictionary. - key - the property name, a plain STRING widget. Type the key you're checking for.
Output is typed BOOLEAN - clean and wire-ready for conditionals.
The dict gotcha - read this
The description promises hasOwnProperty semantics. The shipped port does something else: it checks hasattr(self.obj, key). That works great for Python objects with attributes, but a plain dict's keys are not attributes - I tested _.has on {'a': 1} looking for "a" and it returned False. So on the data dicts you'll actually have in a ComfyUI graph, _.has is effectively broken for key membership. If your real goal is "is this key in this dict," you're better off with a dedicated membership check; _.has today is for objects with attributes, not dicts.
That's a textbook example of the family's "the docs and the code disagree" state - and a good reason the author keeps the whole set labeled work-in-progress.
Why you'd reach for it
When it works - on objects with real attributes - it's a tidy guard for conditional logic. And the typed BOOLEAN output is exactly what IfElse-style nodes want, so the wiring is clean. Just know the dict case is the trap.
Install
ComfyUI Manager, search "comfy-ovum", or:
cd ComfyUI/custom_nodes
git clone https://github.com/sfinktah/comfy-ovum
Restart, under ovum/underscore. No models, no downloads.
Honest warnings
Family disclaimer, and this node is one of the sharpest demonstrations of it. Don't trust the hasOwnProperty description on dicts - test it on your actual data shape first. Chain rule: chain in, chain out, _.value to unwrap.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| py_dictopt | * | Primary input object (expected object). You can still pass any JSON-serializable value. Also accepts _.CHAIN to continue chaining. | |
| keyopt | STRING | key (string) |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| BOOLEAN | BOOLEAN | — |