Situation One
function AAA () { this. Say = "haha"; = "Own"; var New AAA (); Console.log (Obj.say); // "haha"console.log (obj.own); // undefined // "Own"
Situation Two
varperson =function (){ This. pro= "QQQ"; This. Sayword =function (){ return789; };}varCarl =NewPerson (); Console.log (Carl.pro); //"QQQ"Person.prototype.newPro = 123; Console.log (Person.sayword); //undefined here means that the private property is accessed, not the public property of the this declaration within the functionConsole.log (Carl.newpro);//123Console.log (Carl.sayword);//function () {return 789;}
Situation Three
functionobj () {varA = 444; This. B = 456; C=function (){ varQ = 123; } d=456; OBJ.E=741;}varNew_obj =Newobj (); Console.log (NEW_OBJ.A);//undefinedConsole.log (NEW_OBJ.B);//456 Accessing the public properties defined with thisConsole.log (NEW_OBJ.C);//undefinedConsole.log (NEW_OBJ.D);//undefinedConsole.log (NEW_OBJ.E);//undefinedConsole.log (OBJ.A);//undefinedConsole.log (OBJ.B);//undefinedConsole.log (OBJ.C);//undefinedConsole.log (OBJ.D);//undefinedConsole.log (OBJ.E);//741
- After defining a function, pass ". "Number for its added properties and functions, through itself can access to OBJ.E, but this function created by the instance of access to the knife, we call this property static variable, Alive is a static property
Situation Four
functionobj () { This. A = 123; This. B = 456; This. C =function(){ return1234; } }varObj1 =Newobj (); obj1.a= 456; obj1.c= {};//Check whether the modification was successfulConsole.log (obj1.a);//456Console.log (obj1.c);//ObjectvarObj2 =Newobj ();//Check whether the modification was successfulConsole.log (obj2.a);//123Console.log (OBJ2.C);//function () {return 1234;}
- As a result, the Obj1 property modification has no effect on the properties in Obj2, that is, the property in Obj1 and Obj2 has the same name but not a reference
JavaScript Advanced (4) analysis of several special cases---