Yes. I do this from time to time. Recent example, wasn't sure what the event was called in JavaScript when the window changed. Couldn't remember if it was resize or windowResize or whatever.
SE had a sample dummy event listener add function, complete with // do stuff here. I cut and paste the whole thing and added what I needed.
I suppose I could've retyped the addEventListener function from scratch but...I dunno, that seemed inefficient. I just needed the name.