Suppose I have a simple function defined that does nothing: function fn() { }
Now, when I run toString(fn) I get "[object Object]". When I run toString.call(fn) I get "[object Function]". Does anyone know why I get a more specific type when using the call method?
EDIT: This behavior is exhibited in FireFox run through FireBug console. Both toString.constructor and toString.call.constructor yield "Function()".
toString doesn't accept arguments, so toString(fn) is the same as just toString(), which returns an implicit global object, converted to string. toString.call(fn) calls global.toString passing function object as this, but since global.toString is a method of Object, the result is different from Function.toString.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With