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?

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,
Sign up to request clarification or add additional context in comments.

Comments

1

this is the truth :

 alert(   Object.prototype.toString.apply(t)    );

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.