The literal meaning of 1.constructor is construction. It is a property of the object, and its corresponding value is the "constructor" of the object
1 //constructor of an object instantiated by a constructor function2 functionCMF (n,m) {3 This. n=N;4 This. m=m;5 This. mn=function(){6 return This. n+ ' | ' + This. M7 }8 }9 varcmf=NewCMF (' C ', ' Q ')TenConsole.log (Cmf.mn ())//C|q OneConsole.log (Cmf.constructor)//CMF (n, m) A //Here you can see the CMF () instance of the CMF () object, the constructor of which is its intrinsic property. - - //Ii. constructor of basic data Types the varyi=154 -Console.log (Yi.constructor)//Number () - varLi= "Qdz" -Console.log (Li.constructor)//String ()
Constructor of the 2.1 prototypes
1 functionCMF (n,m) {2 This. n=N;3 This. m=m;4 This. mn=function(){5 return This. n+ ' | ' + This. M6 }7 }8 9cmf.prototype.jn=function(){Ten return This. m+ "!" + This. N One } A varcmf=NewCMF (' C ', ' Q ') -Console.log (Cmf.jn ())//Q!c -Console.log (Cmf.prototype)//CMF {jn=function ()} theConsole.log (typeofCmf.prototype)//Object -Console.log (Cmf.prototype.constructor)//CMF (n, m) - //It is shown above that the constructor of the constructor prototype points to the constructor function. How do you understand that the prototype of the constructor is an obj, and what does this obj consist of? is its constructor constructor.
2.2 Constructor of the basic data type
string.prototype.cf=function(n) { /// to String.prototype this obj Add method CF, string multiplication Return new Array (n+1). Join (this) }var d= "D" Console.log (D.CF (///ddddd// String {cf=function ()}// String () // similar to constructors
The constructor of the
prototype/constructor/__proto__.