JavaScript check if anonymous object has a method
Posted
by Baddie
on Stack Overflow
See other posts from Stack Overflow
or by Baddie
Published on 2010-06-09T15:45:58Z
Indexed on
2010/06/09
15:52 UTC
Read the original article
Hit count: 370
How can I check if an anonymous object that was created as such:
var myObj = {
prop1: 'no',
prop2: function () { return false; }
}
does indeed have a prop2 defined?
prop2
will always be defined as a function, but for some objects it is not required and will not be defined.
I tried what was suggested here: http://stackoverflow.com/questions/595766/how-to-determine-if-native-javascript-object-has-a-property-method but I don't think it works for anonymous objects .
© Stack Overflow or respective owner