Object.constructor === Object.constructor.constructor // why?

here https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function property of the constructor of the object instance of the function "indicates the function that creates the prototype of the object." Is this confusing, so is Object.constructor a "function that creates an object prototype"? What object is an “object”?

I am trying to understand why the property of the Object.constructor constructor itself?

as such: Object.constructor === Object.constructor.constructor // why?

Edit: I will find TJ Crowder responds well, but the wording of his words is rather vague (it's hard to understand at first, at least for me). Here's a paraphrased answer:

1) An object is an instance of a Function

2) An object does not have a property called a constructor, so when we call Object.constructor , it actually gives us Object. [[prototype]]. constructor (aka Object .__ proto __. constructor ).

3) Object.constructor (aka Object .__ proto __. Constructor ) is an instance of a Function .

4) Since the Object and Object.constructor (aka Object .__ proto __. Constructor ) are instances of the Function , therefore they both have the __ proto __ property , which refers to the same object. In other words, Object .__ proto__ === Object.constructor .__ proto __ (aka Object .__ proto __. Constructor._proto _ )

5) The string Object.constructor === Object.constructor.constructor is actually equal to the string Object .__ proto __. constructor === Object.constructor .__ proto __. constructor

6) combining steps 4 and 5 gives us Object.constructor === Object.constructor.constructor

7) go to step 4)

+5
2

Object Function, Function Function, .

"" - - . Object, JavaScript, (, Date RegExp). - , , new.

, :

JavaScript -; , . :

function Foo() {
}

:

var f = Foo();

... , f undefined ( Foo ). :

var f = new Foo();

... -, - :

  • .
  • , , Foo.prototype.
  • Foo , this .
  • Foo , Foo ( ), new , 1. ( Foo , , , .)
+4

JavaScript

enter image description here

+5

All Articles