in javascript:
d={one: false, two: true}
d.one
d.two
d.three
I want to be able to differentiate between d.one
and d.three
. By default they both evaluate to false, but in my case they should not be treated the same.
in javascript:
d={one: false, two: true}
d.one
d.two
d.three
I want to be able to differentiate between d.one
and d.three
. By default they both evaluate to false, but in my case they should not be treated the same.
You can do
"one" in d // or "two", etc
or
d.hasOwnProperty("one")
You probably want hasOwnProperty as the in
operator will also return true if the property is on the an object in the prototype chain. eg.
"toString" in d // -> true
d.hasOwnProperty("toString") // -> false