S
S
sasha2014-10-21 07:00:06
JavaScript
sasha, 2014-10-21 07:00:06

How did jqeury.prototype.constructor turn out to be an object?

I do not understand, as far as I know, in the constructor on the prototype there must be an object constructor function.
I.e:

func shit();
shit.prototype.constructor == shit;


And now I’m sitting watching on jquery and trying to understand how the jquery object, when it is called as a function, works like a function, and when methods are called on this function, it works like an object. And I see something like this:

console.log(jq.prototype.constructor); // function (a,b){return new n.fn.init(a,b)}  вроде все ок
console.log(jq.prototype.constructor.prototype==jq.prototype); // true как и ожидалось
console.log(typeof jq.prototype.constructor); // function
console.log(jq.prototype.constructor.ajax); // function (a,b){"object"==typeof a&&(b=a,a=void ........ КАК?!

How to respond to a function as an object and as a function??

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Evgeny Petrov, 2014-10-21
@madmages

A function has methods. What's unusual here?
That's interesting, but this does not lead to prostration?
Functions in Javascript are first-class citizens.

I
iDennis, 2014-10-21
@iDennis

The question is not clear, yet it is logical) or you forgot typeof

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question