hypeDocument.functions() is not an Array


in the documentation hypeDocument.functions() is described to be an array of custom hypefunctions.
Instead it seems to be a object with key = functionname and value = function.

My problem:
I want to iterate thru the object to find a specific key and then run its associated function.
Can’t get it to work without eval-usage. Guess i’m missing something :smile:


if(myIndex != -1) 
 for (var key in hypeFunctions) {
if(key === myFunctions[myIndex])
eval('hypeDocument.functions().' + key + '(hypeDocument, element, event)')//which works as expected, but couldn't be the propper way ...

I am assuming that myIndex is coming from something else and not manually entered .

Therefore the normal way of calling the function:

hypeDocument.functions().funName(hypeDocument, element, event);

will not work for you because it is dependant on the myIndex int from else where as to which function needs to be called.

But why can you not use:


Instead comparing to a list of function names in myFunctions.

well, tried a few combinations, but this doesn’t work either … mainly because hypeDocument.functions() is not an array :slight_smile:

Ah, I see what you mean. I thought I was getting a result but it was an errorless console.log()

How about this.

var  myIndex = 0;
    var hypeFunctions = hypeDocument.functions() ;
    	 var myFunctions = ["func2","func3"];




wow, not bad at all!!!
thx for investigating



1 Like