There's a picture of the truth
function myfun1 () {//This is a private property varPrivate1 ="This is a private property 1"; varPrivatemethod =function () {alert (private1); } //This is an instance property This. Publicvar ="This is the instance attribute 1"; This. Public1 =function () {Privatemethod (); }}//-//--------------//-//--------------------------------- varNEWFUN1 =Newmyfun1 (); Newfun1.public1 ();//This is a private propertyalert (Newfun1.publicvar);//This is an instance propertyalert (newfun1.private1);//undefined Newfun1.privatemethod ();//Run Error//--//--//---///------------------------------------------//--//--//---///-------------------perform 1-------------------//--//--//---///------------------------------------------function myfun2 () {}myfun2.staticvar="This is a static property 2"; Myfun2.staticmethod=function () {alert (Myfun2.staticvar);}//--//--//---///------------------------------------------//--//--//---///-------------------perform 2-------------------//--//--//---///------------------------------------------varNewfun2 =Newmyfun2 ();//Newfun2.staticmethod ();//run error;alert (Newfun2.staticvar);//undefined//------//-------------//-------------------------------//Static Private MembersvarMYFUN3 =(function () {function privateproperty () {} Privateproperty.staticvar="This is a static private member 3"; Privateproperty.staticmethod=function () {alert (Privateproperty.staticvar); } privateproperty.staticmethod (); returnPrivateproperty}) (); alert (Newfun3.staticvar);//This is a static private member 3//---//--------//-----------------//-------------//Static ClassvarFuncount =0;varMyfun4 =Newfunction () {Funcount++; This. PrintCount =function () {alert (funcount); }}myfun4.printcount (); //Output 1;Myfun4.printcount ();//Output 1;Myfun4.prototype.amethod =function () {alert ("Prototype Object 4");}//Run ErrorvarNewfun4 =Newmyfun4 (); Newfun4.amethod ();//------------------//---------------------------------//run error, stating that MYFUN3 cannot be added to a method after it has been created and instantiated, the propertyNewMyfun3.constructor (). PrintCount ();//If you really want to instantiate it, you can.//prototype InheritancevarMyfun5 =function () {}myfun5.prototype.myfun5_extend=function () {alert ("This is 5 of the prototype inheritance.");}varMyfun5_sub =function () {}myfun5_sub.prototype=Newmyfun5 ();varNewfun5 =Newmyfun5_sub (); Newfun5.myfun5_extend ();//This is a prototype inheritance.//Call InheritancevarMyfun6 =function () { This. method_p =function () {alert ("This is the call to inherit the 6"); }}varMyfun6_sub =function () {myfun6. Call ( This);}varNewfun6 =Newmyfun6_sub (); newfun6.method_p ();//This is called by the inherited//covervarMyfun7 =function () { This. method =function () {alert ("This is the parent object Method 7"); }}varMyfun7_sub =function () { This. method =function () {alert ("This is a sub-object method 8"); }}myfun7_sub.prototype=Newmyfun7 ();varNewfun7 =Newmyfun7_sub (); Newfun7.method ();//This is a child object method, and the parent object method is overridden.// polymorphicfunction Myfun8 (A, b) {varA =A; varb =b; if(typeofA = =" Number"&&typeofb = =" Number") {alert (a*b); } Else if(typeofA = ="string"&&typeofb = ="string") {alert (a+b); } Else{alert ("wrong input."); }}MYFUN8 (3,4);//output;MYFUN8 ("Hi,","Hello");//output Hi, hello;MYFUN8 ("Hi",5);//wrong input.
Call and apply and bind