/ Published in: JavaScript
This is a very easy way to check if an object has a given property. Easier than checking if (obj.foo != null) or some such, which is what I've been doing :( From Flanagan, 5th ed, p. 108.; but I actually ran across it in the source of this page: http://www.gtalbot.org/DHTMLSection/DynamicOpacity.html, thanks to Gerard Talbot on clj.
Expand |
Embed | Plain Text
if ("foo" in myObject) {}
You need to login to post a comment.
