Question

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?

Was it helpful?

Solution

myObject.hasOwnProperty("field")

Example Code:

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

trace (dic.hasOwnProperty("field")); //true
trace (dic.hasOwnProperty("nofield")); //false
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top