[javascript] How to check if function exists in JavaScript?