Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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..catch statement?

like image 995
daniel.sedlacek Avatar asked Mar 04 '11 17:03

daniel.sedlacek


People also ask

What is hasOwnProperty?

The hasOwnProperty() method returns a boolean indicating whether the object has the specified property as its own property (as opposed to inheriting it).

Why do we use hasOwnProperty?

JavaScript | hasOwnProperty() Method The hasOwnProperty() method in JavaScript is used to check whether the object has the specified property as its own property. This is useful for checking if the object has inherited the property rather than being it's own.


1 Answers

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");
}
like image 155
scriptocalypse Avatar answered Sep 21 '22 09:09

scriptocalypse