How to reference a function from JavaScript class method