{"id":1094,"date":"2017-03-16T15:50:14","date_gmt":"2017-03-16T07:50:14","guid":{"rendered":"http:\/\/www.qdabc.cn\/?p=1094"},"modified":"2017-03-16T15:50:14","modified_gmt":"2017-03-16T07:50:14","slug":"javascript%e7%bb%a7%e6%89%bf%e5%ae%9e%e7%8e%b0","status":"publish","type":"post","link":"http:\/\/www.qdabc.cn\/?p=1094","title":{"rendered":"JavaScript\u7ee7\u627f\u5b9e\u73b0"},"content":{"rendered":"<pre>&lt;!DOCTYPE HTML PUBLIC \"-\/\/W3C\/\/DTD HTML 4.01\/\/EN\" \"http:\/\/www.w3.org\/TR\/html4\/strict.dtd\"&gt;  \r\n&lt;html&gt;  \r\n    &lt;head&gt;  \r\n        &lt;meta http-equiv=\"Content-Type\" content=\"text\/html; charset=GBK\" \/&gt;  \r\n        &lt;title&gt;\u4f7f\u7528javascript\u5b9e\u73b0\u7ee7\u627f&lt;\/title&gt;  \r\n        &lt;script type=\"text\/javascript\" charset=\"GBK\"&gt;  \r\n            \/\/sub\u662f\u5b50\u7c7b\uff0csup\u662f\u7236\u7c7b  \r\n            function extend(sub,sup){  \r\n                \/\/ \u76ee\u7684\uff1a \u5b9e\u73b0\u53ea\u7ee7\u627f\u7236\u7c7b\u7684\u539f\u578b\u5bf9\u8c61  \r\n                var F = new Function();\/\/ 1 \u521b\u5efa\u4e00\u4e2a\u7a7a\u51fd\u6570    \u76ee\u7684\uff1a\u7a7a\u51fd\u6570\u8fdb\u884c\u4e2d\u8f6c  \r\n                F.prototype = sup.prototype;\/\/ 2 \u5b9e\u73b0\u7a7a\u51fd\u6570\u7684\u539f\u578b\u5bf9\u8c61\u548c\u8d85\u7c7b\u7684\u539f\u578b\u5bf9\u8c61\u8f6c\u6362  \r\n                sub.prototype = new F(); \/\/ 3 \u539f\u578b\u7ee7\u627f   \r\n                sub.prototype.constructor = sub;\/\/4\u8fd8\u539f\u5b50\u7c7b\u7684\u6784\u9020\u5668  \r\n                \/\/\u4fdd\u5b58\u4e00\u4e0b\u7236\u7c7b\u7684\u539f\u578b\u5bf9\u8c61: \u4e00\u65b9\u9762\u65b9\u4fbf\u89e3\u8026  \u53e6\u4e00\u65b9\u9762\u65b9\u4fbf\u83b7\u5f97\u7236\u7c7b\u7684\u539f\u578b\u5bf9\u8c61  \r\n                sub.superClass = sup.prototype;\/\/\u81ea\u5b9a\u4e49\u4e00\u4e2a\u5b50\u7c7b\u7684\u9759\u6001\u5c5e\u6027 \u63a5\u53d7\u7236\u7c7b\u7684\u539f\u578b\u5bf9\u8c61  \r\n                \/\/\u5224\u65ad\u7236\u7c7b\u7684\u539f\u578b\u5bf9\u8c61\u7684\u6784\u9020\u5668 (\u52a0\u4fdd\u9669)  \r\n                if(sup.prototype.constructor == Object.prototype.constructor ){  \r\n                    sup.prototype.constructor = sup;  \r\n                }  \r\n            }  \r\n            \/\/\u5e94\u7528\u4e3e\u4f8b  \r\n            \/\/\u7236\u7c7b  \r\n            function Person(name , age){  \r\n                this.name = name;  \r\n                this.age = age;  \r\n            };  \r\n            Person.prototype = {  \r\n                constructor:Person,  \r\n                sayHello:function(){  \r\n                    alert(\"Hello world\");  \r\n                }  \r\n            };            \r\n            \/\/\u5b50\u7c7b  \r\n            function Boy(name,age,sex){  \r\n                \/\/call \u7ed1\u5b9a\u7236\u7c7b\u7684\u6a21\u7248\u51fd\u6570 \u5b9e\u73b0 \u501f\u7528\u6784\u9020\u51fd\u6570\u7ee7\u627f \u53ea\u590d\u5236\u4e86\u7236\u7c7b\u7684\u6a21\u7248  \r\n                Boy.superClass.constructor.call(this,name,age);  \r\n                this.sex = sex;  \r\n            };  \r\n            \/\/\u539f\u578b\u7ee7\u627f\u7684\u65b9\u5f0f: \u5373\u7ee7\u627f\u4e86\u7236\u7c7b\u7684\u6a21\u7248 \u53c8\u7ee7\u627f\u4e86\u7236\u7c7b\u7684\u539f\u578b\u5bf9\u8c61  \r\n            \/\/Boy.prototype = new Person();  \r\n            \/\/ \u53ea\u7ee7\u627f\u4e00\u904d\u7236\u7c7b\u7684\u539f\u578b\u5bf9\u8c61  \r\n            extend(Boy , Person);  \r\n              \r\n            Boy.prototype.sayHello = function(){  \r\n                alert('hi javascript!');  \r\n            }  \r\n            var b = new Boy('\u5f20\u4e09' , 20 , '\u7537');  \r\n            alert(b.name);   \r\n            alert(b.sex);  \r\n            b.sayHello();  \r\n            Boy.superClass.sayHello.call(b);\/\/\u7236\u7c7b\u7684\u65b9\u6cd5  \r\n                  \r\n        &lt;\/script&gt;  \r\n    &lt;\/head&gt;  \r\n    &lt;body&gt;  \r\n    &lt;\/body&gt;  \r\n&lt;\/html&gt;<\/pre>\n<p>&nbsp;<\/p>\n<p class=\"post-copyright\">\u6b22\u8fce\u5206\u4eab\u672c\u6587\uff0c\u8f6c\u8f7d\u8bf7\u4fdd\u7559\u51fa\u5904\uff1a<a href=\"http:\/\/www.qdabc.cn\">\u524d\u7aefABC<\/a> &raquo; <a href=\"http:\/\/www.qdabc.cn\/?p=1094\">JavaScript\u7ee7\u627f\u5b9e\u73b0<\/a><\/p>","protected":false},"excerpt":{"rendered":"<p>&lt;!DOCTYPE HTML PUBLIC &#8220;-\/\/W3C\/\/DTD HTML 4.01\/\/EN&#8221; &#8220;http:\/\/www.w3.org\/TR\/html4\/strict.dtd&#8221;&gt; &#038;lt [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":319,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[9,81],"_links":{"self":[{"href":"http:\/\/www.qdabc.cn\/index.php?rest_route=\/wp\/v2\/posts\/1094"}],"collection":[{"href":"http:\/\/www.qdabc.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.qdabc.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.qdabc.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.qdabc.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1094"}],"version-history":[{"count":1,"href":"http:\/\/www.qdabc.cn\/index.php?rest_route=\/wp\/v2\/posts\/1094\/revisions"}],"predecessor-version":[{"id":1095,"href":"http:\/\/www.qdabc.cn\/index.php?rest_route=\/wp\/v2\/posts\/1094\/revisions\/1095"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.qdabc.cn\/index.php?rest_route=\/wp\/v2\/media\/319"}],"wp:attachment":[{"href":"http:\/\/www.qdabc.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1094"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.qdabc.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1094"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.qdabc.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1094"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}