Skip to content

Instantly share code, notes, and snippets.

@jinlong
Created April 28, 2013 09:33
Show Gist options
  • Save jinlong/5476409 to your computer and use it in GitHub Desktop.
Save jinlong/5476409 to your computer and use it in GitHub Desktop.
prototype 原型链的方法访问局部变量。
var ClassA = function(){
var a = 111;
this.b = 222;
this.show = function(){
alert(a)
};
};
ClassA.prototype.constructor = ClassA;
ClassA.prototype.showme = function(){
this.show();
}
var aa = new ClassA();
aa.showme();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment