This is a follow up question to This Question.
I like (and understand) the solution there. However, in the code I am working in, another way to solve the same problem is used:
function exist(sFN) { if(self[sFN]) return true; return false; }
It seems to work fine, although I don’t understand how. Does it work? How? What are minuses of this approach? Should I switch to solution from the other question?
Your condition is checking the existence of the ‘sFN’ property in the ‘self’ object. Anything that isn’t null, undefined, 0, and ” will evaluate to true.
As others have said, you can use typeof, or instanceof to see if it’s actually a function.
Looking at your linked example, you should read up on the difference between ==/!= and ===/!== in javascript. Short answer: (” == null) is true, (” === null) is false.