The way events work is pretty significantly different from JavaScript coding, and the typical patterns you'll use to get things done are different. So it's best not to try and think of questions like "how do I make this event in script", it's better to change your perspective to "how do I do what I need to do with JavaScript coding". For example often picking by UID is used when calling functions in events in order to pass an instance, but you should not do this in JavaScript, because you can pass an instance directly. This makes the question "how do I pick by UID?" redundant and basically wrong to ask, so (as is pretty much always the case with help anyway) it's best to focus on your goal and how to get there, not some random details.
I must strongly discourage you from looking at the C2 runtime code. Much of it is nearly 10 years old and you can generally do much better with modern JS features. For example you pointed out some code that is far more suitable for a Map, and the only reason the C2 runtime doesn't do that, is because it didn't exist when it was first written.