instanceof fragile across contexts.  Use typeof for functions.