2

jQuery 1.4.2 in IE 8

When I call $.isFunction(function() {}) it returns true.
Source code isFunction function:

 isFunction: function (obj) {
 return toString.call(obj) === "[object Function]";
 },

When I write in console toString.call(function() {}) === "[object Function]" it throws "Object doesn't support this property or method".

Source code of minified version:

isFunction:function(a){return $.call(a)==="[object Function]"}

When I write in console $.call(function() {})==="[object Function]" it returns false.
Why code works in different ways?

asked Oct 14, 2011 at 9:24
1
  • What are you actually asking here? Commented Oct 14, 2011 at 9:26

2 Answers 2

1

At the top of the JQuery 1.4.2 source (inside the wrapper), toString is defined as Object.prototype.toString. The global toString function is different from the prototyped toString method, hencethe different results.

// Save a reference to some core methods
toString = Object.prototype.toString,
answered Oct 14, 2011 at 9:39
Sign up to request clarification or add additional context in comments.

Comments

1

this is the truth :

 alert( Object.prototype.toString.apply(t) );
answered Oct 14, 2011 at 9:27

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.