Javascript Check If Object Has Method