I have an object called foo. I want to check if it has the property bar.
Should I use this:
if (typeof foo.bar !== "undefined")
Or this:
if ("bar" in foo)
Is there any difference?
I have an object called foo. I want to check if it has the property bar.
Should I use this:
if (typeof foo.bar !== "undefined")
Or this:
if ("bar" in foo)
Is there any difference?