Last active
December 18, 2015 08:59
-
-
Save s2kw/5757826 to your computer and use it in GitHub Desktop.
is prototype able to reference 'this' ?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function obj1(){ | |
this.param1 = 1; | |
this.param2 = 2; | |
} | |
obj1.prototype.ProtoMethod = function(){ | |
this.param1 = 11; | |
this.param2 = 22; | |
} | |
var obj = new obj1(); | |
var befor1 = obj.param1; | |
var befor2 = obj.param2; | |
obj.ProtoMethod(); // <-- | |
var after1 = obj.param1; | |
var after2 = obj.param2; | |
document.getElementById('test').innerHTML = | |
"<br> befor1:"+befor1 + | |
"<br> befor2:"+befor2+ | |
"<br> after1:"+after1+ | |
"<br> after2:"+after2 | |
; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment