<script type= "Text/javascript" >functionlogs (str) {document.write (str+ "<br/>") } //chained calls can be implemented using the "this pointer to function caller" feature. Most of the jQuery is chained calls varOname ={name:"AA", Age:999 }; Window.name= "I am Window"; functionShowName () {logs ( This. Name); } oname.show=ShowName; Window.show=ShowName; Oname.show (); /*AA*/window.show ();/*I am Window*/Oname.showname=function() {logs ( This. Name); return This;//The "This" in JavaScript is a function context that is not determined at the time of the declaration, but is determined at the time of the call. }; Oname.showage=function() {logs ( This. Age); return This; } oname.showname (). Showage (); //AA 999 //method Static method instance method The same attribute instance method in Java must declare an object before the object can invoke the functionStaticclass () {};//declaration of a classStaticclass.staticmethod =function() {logs ("Static Method") }; //Create a static methodStaticClass.prototype.instanceMethod =function() {logs ("Instance method") } //Create an instance methodStaticclass.staticmethod ();//static Method //Staticclass.instancemethod (); Statement error, unable to run NewStaticclass (). Instancemethod ();//must be instantiated to invoke instance method //The essence of the dynamic prototyping approach is to use the prototype Declaration instance method, which declares the instance properties functionCar () { This. color = "None";//examples are if(typeofcar._initialized = = "undefined") {Car.prototype.showCar=function() {//instance MethodLogs This. color); }} car._initialized=true;//static properties? Instance properties?} logs (Car.color); //undefinedLogs (car._initialized);//undefined? varCar =NewCar (); Logs (Car.color); //NoneLogs (car._initialized);//true?Logs (car._initialized);//undefined?Car.showcar ();//None /*car._initialized is the static property 1 error, because your car._initialized property assignment is inside the class, JS is to explain where to perform where, because of this, when there is an instance of Car, static properties _initiali Zed is assigned a value, so 2 is true, and 3 does not output because it is a static property, not an instance property. */</script>
ref:http://sblig.iteye.com/blog/1542896
JavaScript this attribute, static method, and instance method, prototype