- + JavaScript の質問用スレッド vol.117 +
635 :デフォルトの名無しさん[sage]:2015/01/21(水) 22:55:35.13 ID:OM+rl6vx - コード全量載せます。
期待結果:AAAのalert後にBBBのalertが出る 現在:オブジェクトは 'BBB' プロパティまたはメソッドをサポートしていません。 原因がいまいちわからん。。。 <!DOCTYPE html> <html lang="en" xmlns="http://www.w3.org/1999/xhtml"> <head><meta charset="utf-8" /><title></title></head> <script type="text/javascript"> var inherits = function inherits(sub, sup) { var F = function F() { }; F.prototype = sup.prototype; sub.prototype = new F(); sub.prototype.constructor = sub; }; function Common() {}; Common.prototype.AAA = function AAA() { return 'AAA'; }; function Point() { Common.call(this); }; Point.prototype.BBB = function BBB() {return 'BBB';} inherits(Point, Common); function test() { var ponit = new Point(); var aaa = ponit.AAA(); alert(aaa); var bbb = ponit.BBB(); alert(bbb); }; </script> <body><input type="button" onclick="test()" /></body> </html>
|