Posted By

noah on 05/24/07


Tagged

object check test method property easy oo flanagan rhino complangjavascript


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

vali29


Does an object have a specific property?


 / 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.

  1. if ("foo" in myObject) {}

Report this snippet  

You need to login to post a comment.