Posted By

noah on 05/24/07


object check test method property easy oo flanagan rhino complangjavascript

Versions (?)

Who likes this?

1 person have marked this snippet as a favorite


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 ( != 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:, thanks to Gerard Talbot on clj.

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

Report this snippet  

You need to login to post a comment.