Domanda

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?

È stato utile?

Soluzione

myObject.hasOwnProperty("field")

Example Code:

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

trace (dic.hasOwnProperty("field")); //true
trace (dic.hasOwnProperty("nofield")); //false
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top