Javascript Function Parameters


#1

I am currently transitioning from 3+ years of using Adobe Edge (Animate) to Tumult Hype, and have a question regarding Javascript functions. In the past with Edge, I’ve augmented most of my projects with additional Javascript functions and libraries, loaded in the Code window. With Hype, there appears to be a limitation in regards to defining Javascript functions: I’m unable to define additional function parameters to the existing parameters of hypeDocument, element, and event. Is there a simple way to do this?

I can do a work around of defining a supplemental function that is called prior to the main function, that sets global/window variables that the main function can reference, but it’s a bit convoluted to setup. Thanks.


(Jonathan Deutsch) #2

Hype limits the number of parameters as we may decide to add an argument in the future (we’ve done this before, although haven’t recently so perhaps this could be rethought).

Luckily, there’s a JavaScript workaround for this - you can use the arguments variable which is an array of all the arguments sent to the function. JavaScript has no problem sending more parameters and then looking up via this array.


Dynamic variable to function
It's time for Hype 4.0 :)
(Mark Hunte) #3

:joy_cat: Nugget Alert!!

console.log(arguments);  

Seem I have missing this all my short javascript life !!