Since many different js libraries may be loaded from many different sources, I could envision a situation where some utility functions may want to support different inputs depending on what's passed in, and what's passed in might depend on what's loaded, and what's loaded can change at runtime.
That's why many dynamic languages allow access to the type through a string representation.
I guess an alternative is foo.constructor and foo.constructor.name, which will give you a string if you want that.