{"id":75,"date":"2012-01-10T09:04:28","date_gmt":"2012-01-10T01:04:28","guid":{"rendered":"https:\/\/blog.indeex.club\/?p=75"},"modified":"2020-06-20T22:45:31","modified_gmt":"2020-06-20T14:45:31","slug":"javascript-%e6%a8%a1%e6%8b%9f-actionscript-%e7%9a%84%e9%9d%a2%e5%90%91%e5%af%b9%e8%b1%a1","status":"publish","type":"post","link":"https:\/\/blog.indeex.club\/index.php\/2012\/01\/10\/javascript-%e6%a8%a1%e6%8b%9f-actionscript-%e7%9a%84%e9%9d%a2%e5%90%91%e5%af%b9%e8%b1%a1\/","title":{"rendered":"Javascript  \u6a21\u62df Actionscript \u7684\u9762\u5411\u5bf9\u8c61"},"content":{"rendered":"<p>\u7531\u4e8eJavascript\u6ca1\u6709\u7c7b\uff0c\u6240\u4ee5\u5c1d\u8bd5\u6a21\u62df\u4e00\u4e0bActionscript\u7684\u7c7b\uff0c\u4ee5\u8fbe\u5230\u9762\u5411\u5bf9\u8c61\u7684\u6548\u679c\uff1a<\/p>\n<p>\/\/\u7c7b\u7684\u5b9a\u4e49<\/p>\n<p>\/\/\u65b9\u6cd5\u4e00\uff1a\u7c7b\u7684\u4e00\u822c\u5b9a\u4e49\u65b9\u6cd5<\/p>\n<pre><code class=\"language-javascript line-numbers\">function player1(_name) \n\n{ \n\nthis.name = _name; \n\nthis.say = function() {alert(this.name);}; \n\n} \n\nvar p1 = new player1('llinzzi1'); \n\np1.say(); \n\n<\/code><\/pre>\n<p>\/\/\u65b9\u6cd5\u4e8c\uff1aprototype\u5b9a\u4e49\u65b9\u6cd5<\/p>\n<pre><code class=\"line-numbers\">var player2 = function() {} \n\nplayer2.prototype = { \n\nname:'', \n\nsay:function(){ \n\nalert(this.name); \n\n} \n\n} \n\nvar p2 = new player2(); \n\np2.name = 'llinzzi2'; \n\np2.say(); \n<\/code><\/pre>\n<p>\/\/\u65b9\u6cd5\u4e09\uff1a\u4e0a\u9762\u7684\u65b9\u6cd5\u7ed3\u6784\u7f8e\u89c2\uff0c\u4fbf\u6377\uff0c\u4f46\u6784\u5efa\u51fd\u6570\u4e0d\u80fd\u5e26\u53c2\u6570\uff0c\u4fee\u6539\u65b9\u6cd5<\/p>\n<pre><code class=\"line-numbers\">var player3 = function() { \n\nthis.init.apply(this, arguments); \n\n} \n\nplayer3.prototype = { \n\ninit:function(_name){ \n\nthis.name = _name; \n\n}, \n\nsay:function(){ \n\nalert(this.name); \n\n} \n\n} \n\nvar p3 = new player3('llinzzi3'); \n\np3.say(); \n<\/code><\/pre>\n<p>\/\/\u7c7b\u7684\u7ee7\u627f<\/p>\n<p>\/\/\u65b9\u6cd5\u4e00<\/p>\n<pre><code class=\"line-numbers\">var player4 = function(){ \n\nthis.init.apply(this, arguments); \n\n} \n\nplayer4.prototype = new player3; \n\nplayer4.prototype.shout = function(){ \n\nalert(this.name.toUpperCase()); \n\n} \n\nvar p4 = new player4('llinzzi4'); \n\np4.shout(); \n<\/code><\/pre>\n<p>\/\/\u65b9\u6cd5\u4e8c \u4e0a\u9762\u7684\u65b9\u6cd5\u4e0d\u80fd\u91c7\u7528{}\u7684\u65b9\u6cd5\uff0c\u4fee\u6539\u65b9\u6cd5<\/p>\n<pre><code class=\"line-numbers\">Object.extend = function(destination, source) { \n\nfor (var property in source) \n\ndestination[property] = source[property]; \n\nreturn destination; \n\n}; \n\nvar player5 = function(){ \n\nthis.init.apply(this, arguments); \n\n} \n\nObject.extend(Object.extend(player5.prototype,player3.prototype),{ \n\nshout:function(){ \n\nalert(this.name.toUpperCase()); \n\n} \n\n}); \n\nvar p5 = new player5('llinzzi5'); \n\np5.shout(); \n\n\/\/\u518d\u4eceprototype.js\u6284\u4e00\u7aef\u6d4f\u89c8\u5668\u5224\u65ad\u4ee3\u7801 \n\nBrowser = { \n\nIE:     !!(window.attachEvent &amp;&amp; !window.opera), \n\nOpera:  !!window.opera, \n\nWebKit: navigator.userAgent.indexOf('AppleWebKit\/') &gt; -1, \n\nGecko:  navigator.userAgent.indexOf('Gecko') &gt; -1 &amp;&amp; navigator.userAgent.indexOf('KHTML') == -1, \n\nMobileSafari: !!navigator.userAgent.match(\/Apple.*Mobile.*Safari\/) \n\n} \n\nalert(Browser.MobileSafari); \n<\/code><\/pre>\n<p>\u540c\u662fEcmascript 262\u6807\u51c6\uff0cActionscript\u6bd4Javascript\u597d\u7528\u592a\u591a\u4e86\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7531\u4e8eJavascript\u6ca1\u6709\u7c7b\uff0c\u6240\u4ee5\u5c1d\u8bd5\u6a21\u62df\u4e00\u4e0bActionscript\u7684\u7c7b\uff0c\u4ee5\u8fbe\u5230\u9762\u5411\u5bf9\u8c61\u7684\u6548\u679c\uff1a<a href=\"https:\/\/blog.indeex.club\/index.php\/2012\/01\/10\/javascript-%e6%a8%a1%e6%8b%9f-actionscript-%e7%9a%84%e9%9d%a2%e5%90%91%e5%af%b9%e8%b1%a1\/\" class=\"read-more\">Read More<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[4],"_links":{"self":[{"href":"https:\/\/blog.indeex.club\/index.php\/wp-json\/wp\/v2\/posts\/75"}],"collection":[{"href":"https:\/\/blog.indeex.club\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.indeex.club\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.indeex.club\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.indeex.club\/index.php\/wp-json\/wp\/v2\/comments?post=75"}],"version-history":[{"count":1,"href":"https:\/\/blog.indeex.club\/index.php\/wp-json\/wp\/v2\/posts\/75\/revisions"}],"predecessor-version":[{"id":80,"href":"https:\/\/blog.indeex.club\/index.php\/wp-json\/wp\/v2\/posts\/75\/revisions\/80"}],"wp:attachment":[{"href":"https:\/\/blog.indeex.club\/index.php\/wp-json\/wp\/v2\/media?parent=75"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.indeex.club\/index.php\/wp-json\/wp\/v2\/categories?post=75"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.indeex.club\/index.php\/wp-json\/wp\/v2\/tags?post=75"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}