Last active
December 16, 2015 05:59
-
-
Save adamay000/80677128d4539d8e8d70 to your computer and use it in GitHub Desktop.
This file contains 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
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()); |
This file contains 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
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