Skip to content

Instantly share code, notes, and snippets.

@adamay000
Last active December 16, 2015 05:59
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 adamay000/80677128d4539d8e8d70 to your computer and use it in GitHub Desktop.
Save adamay000/80677128d4539d8e8d70 to your computer and use it in GitHub Desktop.
var Klass = function(text){ this.text = text; };
Klass.prototype.method1 = function(){ return this.text + 'のメソッド' };
var descriptor = Object.getOwnPropertyDescriptor(Klass.prototype, 'method1')
, originalFunction = descriptor.value;
descriptor.value = function(){ console.warn('method1 is deprecated'); return originalFunction.apply(this); };
Object.defineProperty(Klass.prototype, 'method1', descriptor);
console.log(new Klass('メソッド1').method1());
var Klass = function(text){ this.text = text; };
Klass.prototype.method1 = function(){ return this.text + 'のメソッド' };
var k = new Klass('メソッド1');
var descriptor = Object.getOwnPropertyDescriptor(Klass.prototype, 'method1')
, originalFunction = descriptor.value;
descriptor.value = function(){ console.warn('method1 is deprecated'); return originalFunction.apply(this); };
Object.defineProperty(Klass.prototype, 'method1', descriptor);
console.log(k.method1());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment