Reputation: 983
I have thisif
condition.
if object.fruit and object.fruit isnt 'mango'
How can ?
be utilised here? I tried using if object.fruit? isnt 'mango'
, but condition passes when object
is empty object.
Upvotes: 1
Views: 60
Reputation: 2346
You want to check for three things:
object?
key of object
object.key isnt 'mango'
All together that's:
if object? and "fruit" of object and object.fruit isnt 'mango'
You can play around with the values of obj
in this demo: http://codepen.io/anon/pen/VLOMpm
Upvotes: 3