I wonder if there is an equivalent of c/++ union in Javascript? I need to use it as a library I use for an Html5 game wants some fixed variable names for the object I pass to a function of this library however it is much easier for me to keep the data in an array for easier calculation.
To give an example, say there is a function ‘F’ in the library which takes a transformation matrix as a parameter. The parameter must have variable names ‘a’, ‘b’, … ‘f’ which correspond to matrix elements(m[0][0], m[0][1] …) consecutively. I have my own matrix class for calculations in which I use an array.
I know that entering the parameter ‘on the fly’, as shown below, sorts out my problem however I don’t want to do that every time I call the function nor I want to write a proxy function.
F({a:m[0][0], b:m[0][1], c:[0][2], d:m[1][0], e:m[1][1], f:[1][2]});
is there any way around that such as union?
No, there’s not.