Dynamically retrieving function names in JavaScript