I’m working on debugging some code someone else wrote (using Mootools as the base library), and I came across this function:
[note, $H(options.text).getKeys()].flatten().each(function(option){
// bunch of stuff happening
});
I’ve never seen this syntax before, with the brackets and the $H notation (eg. [note, $H(options.text).getKeys()]). Can anyone explain how that works or point me to a reference on it?
Thanks!
This basically aggregates two arrays together. Take, for example, this code:
The arrays
[1,2,3]and[4,5,6]are combined (or “flattened”) into a single array,1,2,3,4,5,6.In your code:
note(perhaps another array) and whatevergetKeys()returns are flattened into a single array. Then, a function is performed across each element.Update:
The $H function is a utility function in Mootools that is a shortcut for Hash().