1

How to check if specific key is contained in associative array? I know I can loop over all keys but can I do single-step check?

Dims
  • 47,675
  • 117
  • 331
  • 600

1 Answers1

4
myObject.hasOwnProperty("field")

Example Code:

var dic:Object = new Object();
dic["field"] = "data";

trace (dic.hasOwnProperty("field")); //true
trace (dic.hasOwnProperty("nofield")); //false
Sam DeHaan
  • 10,246
  • 2
  • 40
  • 48