Check key presence in Object in ActionScript?
-
25-05-2021 - |
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?
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