开发者

What is the "hasOwnProperty()" equivalent for interface?

开发者 https://www.devze.com 2023-02-15 08:37 出处:网络
What is the \"hasOwnProperty()\" equivalent for interface? I have found this related bug at Adobe: https://bugs.adobe.com/jira/browse/FB-27683

What is the "hasOwnProperty()" equivalent for interface?

I have found this related bug at Adobe: https://bugs.adobe.com/jira/browse/FB-27683

Any workaround except try..开发者_JS百科catch statement?


Have you considered this?

if("foo" in bar){ ...

where "foo" is the name of a property and bar is the object reference as Interface?

Here it is in action in a real world scenario:

import flash.events.IEventDispatcher;
import flash.events.EventDispatcher;

var i:IEventDispatcher = new EventDispatcher();
if("dispatchEvent" in i){
    trace(" I have dispatchEvent");
}


The other answer is better, but you can also use

i['hasOwnProperty']('dispatchEvent')
0

精彩评论

暂无评论...
验证码 换一张
取 消