For this explanation I assume the array is named array and the parameter through which you pass it is parameter 0.
How do I pass an array as a parameter ?
Enter the parameter you want as "array.uid" (without quotes) when calling the function. Of course make sure that only the specific array you want is picked in the sub-event from which you call the function.
Then in the "on function" event just use an array pick by UID condition as the second condition, enter "function.param(0)" as the UID by which you want to pick. Alternatively if you use your own variable you use to identify arrays, you can just pass that and pick an instance that has the right value.
How do I pass an array as a return value ?
Just use array.UID again, similar to above.
How do I have a local array in an event ?
You can't set an array as local to an event, this is one of the drawbacks of construct 2. There are some workarounds though. One I use is that I have a global dummy array. In the every event/function/whatever/ it is used it first gets cleared, resized. Then I use it as I wish. So far this has not came back to bite me, but knowing how unpredictable loops sometimes are in construct (the "for"/"for each" loops seem to run iterations in parallel rather than sequentially) I only use it in while and repeat loops only or events without loops.
Another is to create the array in the event to use it and destroy it in the end. But this one is not as simple as you might think, because in the tick/frame in which an object is created it cannot be picked events apart from the pick by UID event. A workaround for this is to have a function that creates and object and returns its UID.
The an alternative for one dimensional arrays is to use a local string variable and build a coma "," or semicolon ";" or pipe "|" string where each value is an array element. Then use the tokenat and tokencount expressions to retrieve the element. That is truly local but it has its own limitations.
Same for dictionaries and XML trees...
They also cannot be set to local. I would suggest trying to do something similar as I wrote for arrays.
And how do I count occurrences of an element in an array ?
I assume you meant occurrences of a particular element value (how many time the array contains "foo" for example). This one is simple. Just use a "for each element" array condition. Then add a subevent to the event containing the "for each element" checking the value at "array.CurX" if it matches the desired value. In that subevent add 1 to a local variable tracking occurrences.