Created
February 1, 2011 20:01
-
-
Save mhayashi/806546 to your computer and use it in GitHub Desktop.
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
> A = function(){} | |
function (){} | |
// prototype.constructor にはコンストラクタ自身が入っている | |
> A.prototype.constructor === A | |
true | |
// けど、 A.prototype.constructor を書き換えても、、 | |
> A.prototype.constructor = function(){console.log(1)} | |
function (){console.log(1)} | |
// A には影響がない | |
> A.prototype.constructor === A | |
false | |
// だから new しても 1 が出力されない | |
> a = new A() | |
A | |
// A に直接代入することなく、コンストラクタだけを書き換えることはできる? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment