Skip to content

Instantly share code, notes, and snippets.

@mhayashi
Created February 1, 2011 20:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mhayashi/806546 to your computer and use it in GitHub Desktop.
Save mhayashi/806546 to your computer and use it in GitHub Desktop.
> 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