{"id":3048,"date":"2013-02-26T23:33:36","date_gmt":"2013-02-26T15:33:36","guid":{"rendered":"http:\/\/www.zhangxinxu.com\/wordpress\/?p=3048"},"modified":"2018-01-02T02:33:03","modified_gmt":"2018-01-01T18:33:03","slug":"js-currying","status":"publish","type":"post","link":"https:\/\/www.zhangxinxu.com\/wordpress\/2013\/02\/js-currying\/","title":{"rendered":"JS\u4e2d\u7684\u67ef\u91cc\u5316(currying)"},"content":{"rendered":"<p>by <a href=\"http:\/\/www.zhangxinxu.com\/\">zhangxinxu<\/a> from <a href=\"http:\/\/www.zhangxinxu.com\/\">http:\/\/www.zhangxinxu.com<\/a><br \/>\n\u672c\u6587\u5730\u5740\uff1a<a href=\"http:\/\/www.zhangxinxu.com\/wordpress\/?p=3048\">http:\/\/www.zhangxinxu.com\/wordpress\/?p=3048<\/a><\/p>\n<h3>\u4e00\u3001\u67ef\u91cc\u5316\u548c\u67ef\u5357\u7684\u5173\u7cfb\u662f\uff1f<\/h3>\n<p><strong>\u56de\u7b54<\/strong>\uff1a\u5982\u679c\u6211\u8bf4\u201c\u67ef\u91cc\u5316 == \u67ef\u5357\u201d\u5462\uff1f<br \/>\n<strong>\u4f17\u4eba<\/strong>\uff1a\u535a\u4e3b\uff0cr u ok!? \u662f\u4e0d\u662f\u9493\u9c7c\u9493\u4e45\u4e86\u8111\u888b\u79c0\u9017\u4e86\u54c8\uff1f\u67ef\u91cc\u5316\u53ef\u662f\u51fd\u6570\u5f0f\u7f16\u7a0b\u4e2d\u7684\u4e00\u4e2a\u6280\u5de7\uff0c\u800c\u67ef\u5357\u662f\u5230\u54ea\u513f\u54ea\u513f\u6b7b\u4eba\u300110\u5e74\u4e0d\u8001\u7684\u795e\u8bdd\u822c\u7684\u5b58\u5728\u3002\u516b\u7aff\u5b50\u90fd\u6253\u4e0d\u5230\u7684\uff0c\u600e\u4f1a\u76f8\u7b49\u5462<img decoding=\"async\" src=\"http:\/\/mat1.gtimg.com\/www\/mb\/images\/face\/32.gif\" align=\"absmiddle\">\uff1f\uff1f<\/p>\n<p><strong>\u56de\u7b54<\/strong>\uff1a\u8bf8\u4f4d\uff0c\u773c\u775b\u7741\u5927\u70b9\uff0c\u662f<code>==<\/code>, \u4e0d\u662f<code>===<\/code>\u54e6~<br \/>\n<strong>\u4f17\u4eba<\/strong>\uff1a\u55ef\u54ea\uff0c\u6211\u773c\u775b\u5df2\u7ecf\u77aa\u5f97\u706f\u6ce1\u5927\u4e86<img decoding=\"async\" src=\"http:\/\/mat1.gtimg.com\/www\/mb\/images\/face\/3.gif\" align=\"absmiddle\">\uff0c\u7c91\u7c91\u5e76\u6ca1\u6709\u53d8\u51b0\u6dc7\u6dcb\u554a\uff1f<\/p>\n<p><strong>\u56de\u7b54<\/strong>\uff1a\u8fd9\u4e0d\u5c31\u7ed3\u4e86\u561b\u3002\u6211\u8bf4\u7684\u662f\u5f31\u7b49\u4e8e<code>==<\/code>, \u53c8\u4e0d\u662f\u5f3a\u7b49\u4e8e<code>===<\/code>. \u4f60\u60f3\u90a3\uff0cJS\u7684\u4e16\u754c\u91cc\uff0c<code>0==false<\/code>. \u4f60\u770b\uff0c\u8fd9\u963f\u62c9\u4f2f\u5c4a\u7684\u6570\u5b57<code>0<\/code>\uff0c\u548c\u82f1\u7f8e\u5c4a\u7684\u5355\u8bcd<code>false<\/code>\u4e0d\u5c31\u76f8\u7b49\u4e86\uff0c\u8fd9\u4e24\u4e2a\u5bb6\u4f19\u4e5f\u662f\u516b\u7aff\u5b50\u90fd\u8fbe\u4e0d\u5230\u7684\u54e6\u3002<br \/>\n<strong>\u4f17\u4eba<\/strong>\uff1a<img decoding=\"async\" src=\"http:\/\/mat1.gtimg.com\/www\/mb\/images\/face\/97.gif\" align=\"absmiddle\">\u8fd9\u2026\u2026\u597d\u5427\uff0c\u6751\u5987\u5435\u67b6\u9053\u7406\u591a\uff0c\u6055\u6211\u4eec\u611a\u949d\uff0c\u8fd8\u662f\u770b\u4e0d\u51fa\u6765\u201c\u67ef\u91cc\u5316==\u67ef\u5357\u201d\uff0c\u5594~\u9664\u4e86\u90a3\u4e2a\u201c\u67ef\u201d\u5b57\u662f\u4e00\u6837\u7684\uff0c\u6c42\u89e3\u91ca~~<\/p>\n<p><strong>\u56de\u7b54<\/strong>\uff1a\u767e\u79d1\u4e2d<a href=\"http:\/\/baike.baidu.com\/view\/2804134.htm\">\u67ef\u91cc\u5316<\/a>\u89e3\u91ca\u4e3a\uff1a\u201c@#\uffe5#\uffe5#%*&#038;\u2026\u2026%@#\uffe5<sup>\u2460<\/sup>\u201d\uff0c\u592a\u672f\u8bed\u4e86\uff0c\u6211\u955c\u7247\u770b\u88c2\u624d\u77e5\u5927\u6982\u3002\u82e5\u975e\u8981\u5957\u7528\u5b9a\u4e49\uff08\u89c1\u4e0b\u9762\u7684\u2460\u6807\u6ce8\u7684\u5f15\u7528\uff09\uff0c\u4e2a\u4eba\u89c9\u5f97\uff1a\u201c\u67ef\u91cc\u5316\u201d\u5c31\u50cf\u67d0\u4e9b\u5b98\u5458\u7684\u628a\u620f\uff0c\u5b98\u5458\u8981\u5f047\u4e2a\u8001\u5a46\uff0c\u788d\u4e8e\u56fd\u7b56\uff08\u4e00\u592b\u4e00\u59bb\uff09\u4ee5\u53ca\u5e74\u8001\u5f1f\u8870\uff0c\u8868\u9762\u4e0a\u5c311\u4e2a\u8001\u5a46\uff0c\u5b9e\u9645\u4e0a\u5269\u4e0b\u76846\u4e2a\u6697\u5730\u91cc\u6d88\u5316\u3002\u4ee3\u7801\u8868\u793a\u5c31\u662f\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre>var currying = function(fn) {\n    <span style=\"color:green;\">\/\/ fn \u6307\u5b98\u5458\u6d88\u5316\u8001\u5a46\u7684\u624b\u6bb5<\/span>\n    var args = [].slice.call(arguments, 1);\n    <span style=\"color:green;\">\/\/ args \u6307\u7684\u662f\u90a3\u4e2a\u5408\u6cd5\u8001\u5a46<\/span>\n    return function() {\n        <span style=\"color:green;\">\/\/ \u5df2\u7ecf\u6709\u7684\u8001\u5a46\u548c\u65b0\u641e\u5b9a\u7684\u8001\u5a46\u4eec\u5408\u6210\u4e00\u4f53\uff0c\u65b9\u4fbf\u63a7\u5236<\/span>\n        var newArgs = args.concat([].slice.call(arguments));\n        <span style=\"color:green;\">\/\/ \u8fd9\u4e9b\u8001\u5a46\u4eec\u7528 fn \u8fd9\u4e2a\u624b\u6bb5\u6d88\u5316\u5229\u7528\uff0c\u5b8c\u6210\u97e6\u5c0f\u5b9d\u524d\u8f88\u7684\u58ee\u4e3e\u5e76\u8fd4\u56de<\/span>\n        return fn.apply(null, newArgs);\n    };\n};\n\n<span style=\"color:green;\">\/\/ \u4e0b\u4e3a\u5b98\u5458\u5982\u4f55\u641e\u5b9a7\u4e2a\u8001\u5a46\u7684\u6d4b\u8bd5<\/span>\n<span style=\"color:green;\">\/\/ \u83b7\u5f97\u5408\u6cd5\u8001\u5a46<\/span>\nvar getWife = currying(function() {\n    var allWife = [].slice.call(arguments);\n    <span style=\"color:green;\">\/\/ allwife \u5c31\u662f\u6240\u6709\u7684\u8001\u5a46\u7684\uff0c\u5305\u62ec\u6697\u6e21\u9648\u4ed3\u8fdb\u6765\u7684\u8001\u5a46<\/span>\n    console.log(allWife.join(\";\"));\n}, \"\u5408\u6cd5\u8001\u5a46\");\n\n<span style=\"color:green;\">\/\/ \u83b7\u5f97\u5176\u4ed66\u4e2a\u8001\u5a46<\/span>\ngetWife(\"\u5927\u8001\u5a46\",\"\u5c0f\u8001\u5a46\",\"\u4fcf\u8001\u5a46\",\"\u5201\u86ee\u8001\u5a46\",\"\u4e56\u8001\u5a46\",\"\u9001\u4e0a\u95e8\u8001\u5a46\");\n\n<span style=\"color:green;\">\/\/ \u6362\u4e00\u6279\u8001\u5a46<\/span>\ngetWife(\"\u8d85\u8d8a\u97e6\u5c0f\u5b9d\u7684\u8001\u5a46\");<\/pre>\n<\/div>\n<p>\u4e8e\u662f\uff0c\u7ed3\u679c\u5c31\u662f\uff1a<br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/blog\/201302\/2013-02-25_172541.png\" width=\"460\" height=\"119\" alt=\"\u5b98\u5458-\u8001\u5a46-\u67ef\u91cc\u5316\u529f\u80fd\u7ed3\u679c\u622a\u56fe\" class=\"alignnone\" \/><br \/>\n<strong>\u4f17\u4eba<\/strong>\uff1a\u8fd9\u4e0e\u201c\u67ef\u5357\u201d\u7ae5\u978b\u6709\u561b\u5173\u7cfb\uff1f<img decoding=\"async\" src=\"http:\/\/mat1.gtimg.com\/www\/mb\/images\/face\/98.gif\" align=\"absmiddle\" \/><\/p>\n<blockquote><p>\u2460 \u67ef\u91cc\u5316\uff08Currying\uff09\uff0c\u53c8\u79f0\u90e8\u5206\u6c42\u503c\uff08Partial Evaluation\uff09\uff0c\u662f\u628a\u63a5\u53d7\u591a\u4e2a\u53c2\u6570\u7684\u51fd\u6570\u53d8\u6362\u6210\u63a5\u53d7\u4e00\u4e2a\u5355\u4e00\u53c2\u6570\uff08\u6700\u521d\u51fd\u6570\u7684\u7b2c\u4e00\u4e2a\u53c2\u6570\uff09\u7684\u51fd\u6570\uff0c\u5e76\u4e14\u8fd4\u56de\u63a5\u53d7\u4f59\u4e0b\u7684\u53c2\u6570\u800c\u4e14\u8fd4\u56de\u7ed3\u679c\u7684\u65b0\u51fd\u6570\u7684\u6280\u672f\u3002<\/p><\/blockquote>\n<p><strong>\u56de\u7b54<\/strong>\uff1a\u83ab\u6025\u83ab\u6025\uff0c\u4e14\u542c\u81e3\u59be\u4e00\u66f2\u3002\u767e\u79d1\u4e0a\u7684\u5b9a\u4e49\u662f\u9488\u5bf9\u4f17\u591a\u51fd\u6570\u5f0f\u8bed\u8a00\u800c\u8a00\u7684\uff0c\u6309\u7167Stoyan Stefanov(\u300aJavaScript Pattern\u300b\u4f5c\u8005)\u7684\u8bf4\u6cd5\uff0c\u6240\u8c13\u201c\u67ef\u91cc\u5316\u201d\u5c31\u662f<strong><em>\u4f7f\u51fd\u6570\u7406\u89e3\u5e76\u5904\u7406\u90e8\u5206\u5e94\u7528<\/em><\/strong>\uff0c\u5957\u7528\u4e0a\u9762\u5b98\u5458\u4f8b\u5b50\uff0c\u5c31\u662f\u53ea\u8981\u6709\u5408\u6cd5\u8001\u5a46\u548c\u89c1\u4e0d\u5f97\u7684\u60c5\u5987\u5c31\u884c\uff0c\u6570\u76ee\u4ec0\u4e48\u7684\u968f\u610f\u3002\u4e0d\u8fc7\uff0c\u5982\u679c\u8fd9\u6837\u7406\u89e3\uff0c\u8001\u5a46\u7684\u4f8b\u5b50\u5c31\u4e0d\u7b26\u5408\u56fd\u60c5\uff0c\u53cd\u800c\u66f4\u52a0\u5951\u5408\u7684\u7406\u89e3\u662f\u201c\u67ef\u5357\u201d\u3002<br \/>\n<strong>\u4f17\u4eba<\/strong>\uff1a\u54e6\uff1f\u6d17\u8033\u606d\u542c\uff01<\/p>\n<p><strong>\u56de\u7b54<\/strong>\uff1a\u67ef\u5357\u8eab\u5b50\u867d\u5c0f\uff0c\u4f46\u662f\u91cc\u9762\u4f4f\u7684\u5374\u662f\u5927\u67ef\u5357\uff0c\u4e5f\u5c31\u662f\u4e00\u4e2a<code>function<\/code>\u91cc\u9762\u8fd8\u6709\u4e2a<code>function<\/code>\u3002\u4e0d\u540c\u67ef\u5357\u5904\u7406\u4e0d\u540c\u60c5\u51b5\uff0c\u4f8b\u5982\uff0c\u5c0f\u67ef\u5357\u53ef\u4ee5\u548c&#8230;\u7a0d\u7b49\uff0c\u4ed6\u5973\u670b\u53cb\u53eb\u4ec0\u4e48\u7684\u5fd8\u4e86\uff0c\u6211\u67e5\u67e5&#8230;\u54e6\uff0c\u6bdb\u5229\u5170\u4e00\u8d77\u6d17\u6fa1\u6fa1\uff1b\u4f46\u662f\u5927\u67ef\u5357\u5c31\u4e0d\u884c\u3002\u5c0f\u67ef\u5357\u4e0d\u80fd\u5f53\u9762\u6307\u6b63\u72af\u4eba\uff0c\u9700\u501f\u52a9\u5c0f\u4e94\u90ce\uff1b\u4f46\u662f\uff0c\u5927\u67ef\u5357\u5c31\u53ef\u4ee5\u76f4\u63a5\u8d28\u95ee\u6307\u51fa\u51f6\u624b\u3002\u5c31\u7c7b\u4f3c\u4e8e\uff0c\u5185\u5916<code>function<\/code>\u5904\u7406\u4e0d\u540c\u7684\u53c2\u6570\u3002\u5982\u679c\u4ee3\u7801\u8868\u793a\u5c31\u662f(\u5c0f\u67ef\u5357=<code>smallKenan<\/code>; \u5927\u67ef\u5357=<code>bigKenan<\/code>; \u5c0f\u67ef\u5357\u55d1\u836f\u4f1a\u53d8\u5927\u67ef\u5357)\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre>var smallKenan = function(action) {\n    var bigKenan = function(doing) {\n        var result = \"\";\n        if (action === \"take drugs\") {\n            if (doing === \"bathWithGirlFriend\") {\n                result = \"\u5c16\u53eb\uff0c\u65b0\u4e00\uff0c\u4f60\u8fd9\u4e2a\u8272\u72fc\uff0c\u7136\u540e\u4e00\u5df4\u638c\uff0c\u8138\u716e\u719f\u4e86~\";\n            } else if (doing === \"pointOutKiller\") {\n                result = \"\u65b0\u4e00\uff0c\u8fd9\u4e2a\u6848\u5b50\u5c31\u4ea4\u7ed9\u4f60\u7684\uff0c\u5feb\u70b9\u627e\u51fa\u8c01\u662f\u51f6\u624b\u5427~\";\n            }\n        } else {\n            if (doing === \"bathWithGirlFriend\") {\n                result = \"\u6765\u5427\uff0c\u67ef\u5357\uff0c\u4e00\u8d77\u6d17\u6fa1\u5427~\";\n            } else if (doing === \"pointOutKiller\") {\n                result = \"\u5c0f\u5b69\u5b50\u5bb6\uff0c\u6eda\u4e00\u8fb9\u53bb\uff01\";\n            }\n        }\n        console.log(result);\n        return arguments.callee; <span style=\"color:green;\">\/\/ \u7b49\u540c\u4e8ereturn bigKenan<\/span>\n    };\n    return bigKenan;\n};\n\n<span style=\"color:green;\">\/\/ \u5c0f\u67ef\u5357\u5403\u836f\u4e86\uff0c\u7136\u540e\u548c\u6bdb\u5229\u5170\u6d17\u6fa1\uff0c\u51f6\u6848\u73b0\u573a\u6307\u8bc1\u72af\u4eba\uff1b\u7ed3\u679c\u662f\u2026\u2026<\/span>\n<span style=\"color:#cd0000;\">smallKenan(\"take drugs\")(\"bathWithGirlFriend\")(\"pointOutKiller\");<\/span><\/pre>\n<\/div>\n<p>\u7ed3\u679c\u5982\u4e0b\u622a\u56fe\uff1a<br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\" http:\/\/image.zhangxinxu.com\/image\/blog\/201302\/2013-02-26_094039.png\" width=\"381\" height=\"86\" alt=\"\u67ef\u5357\u5403\u836f\u540e\u6d17\u6fa1\u6307\u6b63\u51f6\u72af\u7ed3\u679c\" class=\"alignnone\" \/><\/p>\n<p>\u201c\u5403\u836f\u201d\u3001\u201c\u6d17\u6fa1\u201d\u3001\u201c\u6307\u51fa\u51f6\u624b\u201d\u5c31\u53ef\u4ee5\u770b\u6210\u4e09\u4e2a\u53c2\u6570\uff0c\u5176\u4e2d\uff0c\u201c\u5403\u836f\u201d\u786e\u5b9e\u662f\u5c0f\u67ef\u5357\u4f7f\u7528\u7684\uff0c\u800c\u540e\u9762\u7684\u662f\u201c\u6d17\u6fa1\u201d\u3001\u201c\u6307\u51fa\u51f6\u624b\u201d\u867d\u7136\u8ddf\u5728<code>smallKenan()<\/code>\u540e\u9762\uff0c\u5b9e\u9645\u4e0a\u662f\u5927\u67ef\u5357\u4f7f\u7528\u7684\u3002\u8fd9\u4e2a\u5c31\u662f\u67ef\u91cc\u5316\uff0c\u53c2\u6570\u90e8\u5206\u4f7f\u7528\u3002\u5916\u90e8\u51fd\u6570\u5904\u7406\u90e8\u5206\u5e94\u7528\uff0c\u5269\u4e0b\u7684\u7531\u5916\u90e8\u51fd\u6570\u7684\u8fd4\u56de\u51fd\u6570\u5904\u7406\u3002<\/p>\n<p>\u6240\u4ee5\uff0c\u6211\u8bf4\u201c\u67ef\u91cc\u5316==\u67ef\u5357\u201d\u4e0d\u662f\u80e1\u626f\u5427~~<br \/>\n<strong>\u4f17\u4eba<\/strong>\uff1a\u6211\u4eec\u64e6~~\uff0c\u535a\u4e3b\u626f\u6de1\u7684\u529f\u529bTM\u73b0\u5728\u66f4\u4e0a\u4e00\u5c42\u697c\u5566\uff0c\u8bf4\u5f97\u8fd8\u771f\u90a3\u4e48\u56de\u4e8b\uff01<\/p>\n<h3>\u4e8c\u3001\u67ef\u91cc\u5316\u6709\u4ec0\u4e48\u4f5c\u7528\uff1f<\/h3>\n<p><strong>\u4f17\u4eba<\/strong>\uff1a\u6574\u8fd9\u4e48\u591a\u795e\u4e4e\u5176\u795e\u7684\u4e1c\u897f\uff0c\u6709\u4e2a\u6bdb\u7ebf\u7528\uff1f\u610f\u6deb\u4e00\u4e9b\u6240\u8c13\u7684\u6280\u672f\uff0c\u4e3a\u4e86\u6280\u672f\u800c\u6280\u672f\u6700\u8ba9\u4eba\u8bdf\u75c5\u4e86\uff0c\u6211\u8001\u8001\u5b9e\u5b9e<code>if else<\/code>\u7167\u6837\u811a\u672c\u8dd1\u5f97\u6760\u6760\u7684\uff01<\/p>\n<p><strong>\u56de\u7b54<\/strong>\uff1a\u5509\uff0c\u5927\u5bb6\u6240\u8a00\u6781\u662f\u3002\u82cd\u8747\u868a\u5b50\u55e1\u55e1\u4e0d\u505c\u4e5f\u8ba9\u4eba\u8bdf\u75c5\uff0c\u4f46\u662f\uff0c\u4e5f\u662f\u6709\u5176\u5b58\u5728\u7684\u7406\u7531\u7684\uff0c\u6211\u4eec\u4e0d\u59a8\u770b\u770b~~<br \/>\n<strong>\u4f17\u4eba<\/strong>\uff1a<img decoding=\"async\" src=\"http:\/\/mat1.gtimg.com\/www\/mb\/images\/face\/163.gif\" align=\"absmiddle\"><\/p>\n<p><strong>\u56de\u7b54<\/strong>\uff1a\u8c8c\u4f3c\u67ef\u91cc\u5316\u67093\u4e2a\u5e38\u89c1\u4f5c\u7528\uff1a<strong>1. \u53c2\u6570\u590d\u7528<\/strong>\uff1b<strong>2. \u63d0\u524d\u8fd4\u56de\uff1b<\/strong><strong>3. \u5ef6\u8fdf\u8ba1\u7b97\/\u8fd0\u884c<\/strong>\u3002<br \/>\n1. \u201c\u53c2\u6570\u590d\u7528\u201d\u4e0a\u9762\u5df2\u7ecf\u5c55\u793a\u8fc7\u4e86\uff0c\u5b98\u5458\u8001\u5a46\u7684\u4f8b\u5b50\u5c31\u662f\uff0c\u65e0\u8bba\u54ea\u4e2a\u5b98\u5458\uff0c\u90fd\u662f\u9700\u8981\u4e00\u4e2a\u5408\u6cd5\u8001\u5a46\uff1b\u901a\u8fc7\u67ef\u91cc\u5316\u8fc7\u7a0b\uff0c<code>getWife()<\/code>\u65e0\u9700\u6dfb\u52a0\u8fd9\u4e2a\u591a\u4f59\u7684\u201c\u5408\u6cd5\u8001\u5a46\u201d\u53c2\u6570\u3002<br \/>\n2. \u201c\u63d0\u524d\u8fd4\u56de\u201d\uff0c\u5f88\u5e38\u89c1\u7684\u4e00\u4e2a\u4f8b\u5b50\uff0c\u517c\u5bb9\u73b0\u4ee3\u6d4f\u89c8\u5668\u4ee5\u53caIE\u6d4f\u89c8\u5668\u7684\u4e8b\u4ef6\u6dfb\u52a0\u65b9\u6cd5\u3002\u6211\u4eec\u6b63\u5e38\u60c5\u51b5\u53ef\u80fd\u4f1a\u8fd9\u6837\u5199\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre>var addEvent = function(el, type, fn, capture) {\n    if (window.addEventListener) {\n        el.addEventListener(type, function(e) {\n            fn.call(el, e);\n        }, capture);\n    } else if (window.attachEvent) {\n        el.attachEvent(\"on\" + type, function(e) {\n            fn.call(el, e);\n        });\n    } \n};<\/pre>\n<\/div>\n<p>\u4e0a\u9762\u7684\u65b9\u6cd5\u6709\u4ec0\u4e48\u95ee\u9898\u5462\uff1f\u5f88\u663e\u7136\uff0c\u6211\u4eec\u6bcf\u6b21\u4f7f\u7528<code>addEvent<\/code>\u4e3a\u5143\u7d20\u6dfb\u52a0\u4e8b\u4ef6\u7684\u65f6\u5019\uff0c(eg. IE6\/IE7)\u90fd\u4f1a\u8d70\u4e00\u904d<code>if...else if ...<\/code>\uff0c\u5176\u5b9e\u53ea\u8981\u4e00\u6b21\u5224\u5b9a\u5c31\u53ef\u4ee5\u4e86\uff0c\u600e\u4e48\u505a\uff1f&#8211;\u67ef\u91cc\u5316\u3002\u6539\u4e3a\u4e0b\u9762\u8fd9\u6837\u5b50\u7684\u4ee3\u7801\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre>var addEvent = (function(){\n    if (window.addEventListener) {\n        return function(el, sType, fn, capture) {\n            el.addEventListener(sType, function(e) {\n                fn.call(el, e);\n            }, (capture));\n        };\n    } else if (window.attachEvent) {\n        return function(el, sType, fn, capture) {\n            el.attachEvent(\"on\" + sType, function(e) {\n                fn.call(el, e);\n            });\n        };\n    }\n})();<\/pre>\n<\/div>\n<p>\u521d\u59cb<code>addEvent<\/code>\u7684\u6267\u884c\u5176\u5b9e\u503c\u5b9e\u73b0\u4e86\u90e8\u5206\u7684\u5e94\u7528\uff08\u53ea\u6709\u4e00\u6b21\u7684<code>if...else if...<\/code>\u5224\u5b9a\uff09\uff0c\u800c\u5269\u4f59\u7684\u53c2\u6570\u5e94\u7528\u90fd\u662f\u5176\u8fd4\u56de\u51fd\u6570\u5b9e\u73b0\u7684\uff0c\u5178\u578b\u7684\u67ef\u91cc\u5316\u3002<\/p>\n<p>3. \u201c\u5ef6\u8fdf\u8ba1\u7b97\u201d\uff0c\u4e00\u822c\u800c\u8a00\uff0c\u5ef6\u8fdf\u8ba1\u7b97\u6216\u8fd0\u884c\u662f\u6ca1\u6709\u5fc5\u8981\u7684\uff0c\u56e0\u4e3a\u4e00\u5929\u82b110\u5757\u94b1\u548c\u6708\u672b\u82b1300\u5757\u94b1\u6ca1\u4ec0\u4e48\u672c\u8d28\u533a\u522b\u2014\u2014\u53ea\u662f\u5fc3\u91cc\u597d\u53d7\u70b9\uff08\u6e29\u6c34\u7096\u9752\u86d9\uff09\u3002\u561b\uff0c\u6bd5\u7adf\u53ea\u662f\u4e2a\u4eba\u770b\u6cd5\uff0c\u60a8\u53ef\u80fd\u4f1a\u4e0d\u8fd9\u4e48\u8ba4\u4e3a\u3002\u4e3e\u4e2a\u4f8b\u5b50\uff0c\u6211\u6bcf\u5468\u672b\u90fd\u8981\u53bb\u9493\u9c7c\uff0c\u6211\u60f3\u77e5\u9053\u621112\u6708\u4efd4\u4e2a\u5468\u672b\u603b\u5171\u9493\u4e86\u51e0\u65a4\u9c7c\uff0c\u628a\u4e00\u4e9b\u6240\u8c13\u7684\u6a21\u5f0f\u3001\u6982\u5ff5\u629b\u5f00\uff0c\u6211\u4eec\u53ef\u80fd\u5c31\u4f1a\u4e0b\u9762\u8fd9\u6837\u5b9e\u73b0\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre>\nvar fishWeight = 0;\nvar addWeight = function(weight) {\n    fishWeight += weight;\n};\n\naddWeight(2.3);\naddWeight(6.5);\naddWeight(1.2);\naddWeight(2.5);\n\nconsole.log(fishWeight);   <span style=\"color:green;\">\/\/ 12.5<\/span>\n<\/pre>\n<\/div>\n<p>\u6bcf\u6b21<code>addWeight<\/code>\u90fd\u4f1a\u7d2f\u52a0\u9c7c\u7684\u603b\u91cd\u91cf\u3002<\/p>\n<p>\u82e5\u662f\u6709\u67ef\u91cc\u5316\u5b9e\u73b0\uff0c\u5219\u4f1a\u662f\u4e0b\u9762\u8fd9\u6837\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre>var curryWeight = function(fn) {\n    var _fishWeight = [];\n    return function() {\n        if (arguments.length === 0) {\n            return fn.apply(null, _fishWeight);\n        } else {\n            _fishWeight = _fishWeight.concat([].slice.call(arguments));\n        }\n    }\n};\nvar fishWeight = 0;\nvar addWeight = curryWeight(function() {\n    var i=0; len = arguments.length;\n    for (i; i&lt;len; i+=1) {\n        fishWeight += arguments[i];\n    }\n});\n\naddWeight(2.3);\naddWeight(6.5);\naddWeight(1.2);\naddWeight(2.5);\naddWeight();    <span style=\"color:green;\">\/\/  \u8fd9\u91cc\u624d\u8ba1\u7b97<\/span>\n\nconsole.log(fishWeight);    <span style=\"color:green;\">\/\/ 12.5<\/span><\/pre>\n<\/div>\n<p><strong>\u4f17\u4eba<\/strong>\uff1a\u6211\u52d2\u4e2a\u53bb\uff0c\u597d\u9ad8\u7684\u697c\u554a<img decoding=\"async\" src=\"http:\/\/mat1.gtimg.com\/www\/mb\/images\/face\/0.gif\" align=\"absmiddle\">\uff0c\u76f8\u6bd4\u4e4b\u4e0b\u3002<\/p>\n<p><strong>\u56de\u7b54<\/strong>\uff1a\u786e\u5b9e\uff0c\u67ef\u91cc\u5316\u7684\u5b9e\u73b0\u4f3c\u4e4e\u5570\u55e6\u4e86\u70b9\u3002\u8001\u5988\u7684\u5570\u55e6\u663e\u7136\u4e0d\u662f\u7528\u6765\u6d88\u8017\u591a\u4f59\u7684\u53e3\u6c34\u7684\u3002\u8fd9\u91cc\u7684<code>curryWeight<\/code>\u65b9\u6cd5\u5570\u55e6\u7684\u610f\u4e49\u5728\u4e8e<strong>\u67ef\u91cc\u5316\u7684\u590d\u7528<\/strong>\u3002\u6bd4\u65b9\u8bf4\uff0c\u6211\u8fd8\u60f3\u77e5\u9053\u5e73\u5747\u6bcf\u6b21\u9493\u8d27\u7684\u91cd\u91cf\uff0c\u5219\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre>var averageWeight = 0;\nvar addWeight = curryWeight(function() {\n    var i=0; len = arguments.length;\n    for (i; i&lt;len; i+=1) {\n        averageWeight += arguments[i]\/len;\n    }\n});\n\naddWeight(2.3);\naddWeight(6.5);\naddWeight(1.2);\naddWeight(2.5);\naddWeight();    <span style=\"color:green;\">\/\/  \u8fd9\u91cc\u624d\u8ba1\u7b97<\/span>\n\nconsole.log(averageWeight);    <span style=\"color:green;\">\/\/ 3.125<\/span><\/pre>\n<\/div>\n<p>\u867d\u7136\u5ef6\u8fdf\u8ba1\u7b97\u542c\u4e0a\u53bb\u5f88\u9ad8\u7ea7\uff0c\u4f46\u662f\uff0c\u6055\u6211\u611a\u949d\uff0c\u6211\u60f3\u7834\u4e86\u8111\u888b\u4e5f\u6ca1\u60f3\u51fa\u54ea\u79cd\u60c5\u51b5\u975e\u8981\u67ef\u91cc\u5316\u5ef6\u8fdf\u8ba1\u7b97\u5b9e\u73b0\u624d\u80fd\u663e\u8457\u63d0\u9ad8\u6027\u80fd\u3002\u80fd\u60f3\u5230\u7684\u597d\u5904\u5c31\u662f\u53c2\u6570\u4e2a\u6570\u968f\u610f\uff0c\u6bd4\u65b9\u8bf4\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre>addWeight(2.3, 6.5);\naddWeight(1.2, 2.5);<\/pre>\n<\/div>\n<p>\u4e5f\u662f\u53ef\u4ee5\u7684\u3002<\/p>\n<p><strong>\u8865\u5145\u4e8e\u7fcc\u65e5\uff1a<\/strong>\u7ecf\u4eba\u63d0\u70b9\uff0c\u53d1\u73b0\u81ea\u5df1\u5fd8\u4e86\u4e2a\u4e1c\u897f\uff0cES5\u4e2d\u7684<code>bind<\/code>\u65b9\u6cd5\uff0c\u7528\u6765\u6539\u53d8<code>Function<\/code>\u6267\u884c\u65f6\u5019\u7684\u4e0a\u4e0b\u6587\uff08\u51fd\u6570\u4e3b\u4f53\u672c\u8eab\u4e0d\u6267\u884c\uff0c\u4e0e<code>call<\/code>\/<code>apply<\/code>\u76f4\u63a5\u6267\u884c\u5e76\u6539\u53d8\u4e0d\u540c\uff09\uff0c\u672c\u8d28\u4e0a\u5c31\u662f\u5ef6\u8fdf\u6267\u884c\u3002\u4f8b\u5982\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre>var obj = {\n    \"name\": \"currying\" \n},\nfun = function() {\n    console.log(this.name);\n}<span style=\"color:#cd0000;\">.bind(obj)<\/span>;\n\nfun(); <span style=\"color:green;\">\/\/ currying<\/span><\/pre>\n<\/div>\n<p>\u4eceIE6~8\u7684\u81ea\u5b9a\u4e49\u6269\u5c55\u6765\u770b\uff0c\u5176\u5b9e\u73b0\u7684\u673a\u5236\u5c31\u662f\u67ef\u91cc\u5316\uff08\u4e0d\u8003\u8651\u6267\u884c\u65f6\u7684\u65b0\u589e\u53c2\u6570\uff09\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre>if (!function() {}.bind) {\n    Function.prototype.bind = function(context) {\n        var self = this\n            , args = Array.prototype.slice.call(arguments);\n            \n        return function() {\n            return self.apply(context, args.slice(1));    \n        }\n    };\n}<\/pre>\n<\/div>\n<p>\u5173\u4e8eES5\u4e2d<code>bind<\/code>\u65b9\u6cd5\u81ea\u5b9a\u4e49\u53ef\u53c2\u89c1\u6211\u4e4b\u524d\u7684\u201c<a href=\"http:\/\/www.zhangxinxu.com\/wordpress\/?p=2689\">ECMAScript 5\u4e2dbind\u65b9\u6cd5\u3001\u81ea\u5b9a\u4e49\u53ca\u5c0f\u62d3\u5c55<\/a>\u201d\u4e00\u6587\u3002<\/p>\n<h3>\u4e09\u3001\u6ca1\u6709\u95ee\u7b54\u7684\u7ed3\u675f\u8bed<\/h3>\n<p>\u6700\u8fd1\u5728\u770b\u300aJavaScript\u6a21\u5f0f\u300b\u4e00\u4e66\uff0c\u5929\u54ea\uff0c\u91cc\u9762\u51fa\u73b0\u7684\u5404\u79cd\u8bbe\u8ba1\u6a21\u5f0f\uff08\u5982\u5de5\u5382\u6a21\u5f0f\u3001\u5916\u89c2\u6a21\u5f0f\u3001\u89c2\u5bdf\u8005\u6a21\u5f0f\uff09\uff0c\u4e00\u53cc\u624b\u90fd\u6570\u4e0d\u8fc7\u6765\u3002\u800c\u4e14\u8fd9\u4e9b\u540d\u8bcd\u53c8\u5f88\u62bd\u8c61\uff0c\u4e66\u4e00\u5408\uff0c\u9a6c\u4e0a\u5927\u773c\u77aa\u5c0f\u773c\u4e86\u3002\u8fd9\u79cd\u611f\u89c9\u5c31\u50cf\u662f\uff0c\u623f\u95f4\u91cc\u6765\u4e8610\u4e2a\u9ed1\u4eba\uff0c\u6bcf\u4e2a\u9ed1\u4eba\u90fd\u6709\u4e00\u4e2a\u201c\uffe5%#\u2026\uffe5\u201d\u7684\u540d\u5b57\uff0c\u597d\u4e0d\u5bb9\u6613\u52c9\u5f3a\u8bb0\u4f4f\u4e86\uff0c\u706f\u4e00\u5173\u623f\u95f4\u4e00\u9ed1\uff0c\u7b49\u518d\u5f00\u706f\u7684\u65f6\u5019\uff0c\u6bcf\u4e2a\u9ed1\u4eba\u7684\u540d\u5b57\u90fd\u53d8\u6210&#8230;..&#8221;hello&#8221;\u4e86<img decoding=\"async\" src=\"http:\/\/img.t.sinajs.cn\/t4\/appstyle\/expression\/ext\/normal\/c7\/lxhzhuakuang_thumb.gif\">\u3002<\/p>\n<p>\u5176\u5b9e\u8fd9\u4e9b\u6a21\u5f0f\u5728\u5b9e\u9645\u4f7f\u7528\u7684\u65f6\u5019\uff0c\u6216\u591a\u6216\u5c11\u90fd\u4f7f\u7528\u8fc7\uff0c\u5f53\u770b\u5230\u201c**\u6a21\u5f0f\u201d\u6982\u5ff5\u7684\u65f6\u5019\uff0c\u6211\u4eec\u5c31\u4f1a\u731b\u7136\u60ca\u8d77\uff1a\u201c\u54e6\uff0c\u539f\u6765\u8fd9\u4e2a\u5c31\u53eb\u505a\u2018\u89c2\u5bdf\u8005\u6a21\u5f0f\u2019\u7b49\u201d\u3002\u73b0\u5728\u8981\u8ba8\u8bba\u7684\u95ee\u9898\u662f\uff0c\u6211\u4eec\u6709\u6ca1\u6709\u5fc5\u8981\u628a\u8fd9\u4e9b\u201c**\u6a21\u5f0f\u201d\u90fd\u8bb0\u4f4f\u5462\uff0c\u90fd\u7406\u89e3\u5176\u5bf9\u5e94\u7684\u6838\u5fc3\u5462\uff1f\u8fd9\u4e2a\u95ee\u9898\u7c7b\u4f3c\u4e8e\uff0c\u6211\u53ef\u4ee5\u770b\u61c2NBA\u7684\u7bee\u7403\u6bd4\u8d5b\uff0c\u90a3\u6211\u6709\u6ca1\u6709\u5fc5\u8981\u628a\u5404\u4e2a\u7403\u961f\u4ee5\u53ca\u7403\u961f\u7684\u961f\u5458\u90fd\u8bb0\u4f4f\u5462\uff1f<\/p>\n<p>\u5982\u679c\u60f3\u6210\u4e3aJS\u5927\u795e\uff0c\u4ece\u8fd9\u4e2a\u76ee\u6807\u6765\u770b\uff0c\u8fd9\u662f\u9700\u8981\u7684\uff1b\u597d\u6bd4\u4f18\u79c0\u7684\u7bee\u7403\u89e3\u8bf4\u5458\u5fc5\u987b\u8981\u77e5\u9053\u6bcf\u4e2a\u7403\u961f\u7684\u540d\u5b57\u3001\u7403\u5458\u751a\u81f3\u5468\u8fb9\u516b\u5366\u3002\u4f46\u662f\uff0c\u73b0\u5b9e\u5f88\u91cd\u8981\u3002\u5982\u679c\u8fdeJS\u51fd\u6570\u76f8\u5173\u7684\u57fa\u672c\u4e1c\u897f\u90fd\u9a7e\u9a6d\u4e0d\u597d\uff0c\u663e\u7136\uff0c\u786c\u662f\u5543\u8fd9\u4e9b\u4f3c\u61c2\u975e\u61c2\u7684\u6982\u5ff5\u53ea\u4f1a\u9020\u6210\u6df7\u4e71\u3002\u5982\u679c\u4f60\u89c9\u5f97\u53ef\u4ee5\u66f4\u8fd1\u4e00\u6b65\uff0c\u5148\u901a\u900f\u51e0\u4e2a\u81ea\u5df1\u4e60\u60ef\u7684\u719f\u6089\u7684\u4f7f\u7528\u6a21\u5f0f\uff0c\u8db3\u591f\u5e94\u4ed8\u5b9e\u9645\u9879\u76ee\uff1b\u5176\u4ed6\u4e00\u4e9b\u6982\u5ff5\u4ec0\u4e48\u7684\uff0c\u66f4\u591a\u7684\u53ea\u662f\u5671\u5934\uff0c\u5b9e\u7528\u6027\u5176\u5b9e\u5e76\u4e0d\u5927\u3002\u6b63\u5982\u672c\u6587\u7684\u67ef\u91cc\u5316\uff0c\u770b\u4e0a\u53bb\u5f88\u9ad8\u7ea7\uff0c\u4f3c\u4e4e\u4e5f\u6709\u70b9\u7528\u5904\uff0c\u7136\u800cJS\u7684\u7075\u6d3b\u6027\u4f7f\u5f97\u5f88\u591a\u5b9e\u73b0\u5b8c\u5168\u6446\u8131\u201c\u67ef\u91cc\u5316\u201d\u8fd9\u4e2a\u6982\u5ff5\u7684\u675f\u7f1a\uff0c\u4ee5\u66f4\u901a\u4fd7\u6613\u61c2\u7684\u65b9\u5f0f\u5b9e\u73b0\u3002<\/p>\n<p>\u7136\u800c\uff0c\u5373\u4f7f\u5b9e\u7528\u6027\u4e0d\u9ad8\uff0c\u6211\u4eec\u8fd8\u662f\u8981\u6709\u6240\u4e86\u89e3\uff0c\u56e0\u4e3a\uff0c\u4f60\u4e0d\u77e5\u9053\u4ec0\u4e48\u65f6\u5019\u4f1a\u7528\u5230\u5b83\u3002\u6bd4\u65b9\u8bf4CSS\u4e2d\u7684<code>display:table;<\/code>\u67d0\u4e9b\u60c5\u51b5\u4e0b\u53ef\u4ee5\u89e3\u51b3\u4e00\u4e9b\u68d8\u624b\u95ee\u9898(secret!<img decoding=\"async\" src=\"http:\/\/mat1.gtimg.com\/www\/mb\/images\/face\/187.gif\" align=\"absmiddle\">). <\/p>\n<p>\u56e0\u6b64\uff0c\u672c\u6587\u7684\u67ef\u91cc\u5316\u81f3\u5c11\u8981\u77e5\u9053\u4e2a\u5927\u6982\uff0c\u5982\u679c\u4f60\u56eb\u56f5\u541e\u67a3\u5f0f\u7684\u770b\u5230\u6b64\u5904\uff0c\u53ea\u8bb0\u5f97\u201c\u67ef\u91cc\u5316==\u67ef\u5357\u201d\uff0c\u4f60\u53ef\u4ee5\u518d\u7a0d\u5fae\u9759\u70b9\u5fc3\u91cd\u65b0\u770b\u4e00\u4e0b\u3002\u6211\u7684\u7b14\u5934\u8981\u6bd4\u5634\u5df4\u7280\u5229\u7684\u591a\uff0c\u56e0\u4e3a\uff0c\u6587\u5b57\u6211\u53ef\u4ee5\u9759\u5fc3\u7422\u78e8\uff1a\u201c\u5982\u4f55\u8bb2\u8ff0\u624d\u80fd\u63d0\u8d77\u5174\u8da3\uff0c\u624d\u80fd\u8ba9\u65b0\u624b\u4e5f\u80fd\u77e5\u5176\u610f\u4f1a\u5176\u5f62\uff1f\u201d \uff0c\u4e45\u800c\u4e45\u4e4b\uff0c\u5c31\u5f62\u6210\u4e86\u8fd9\u79cd\u83ca\u7d27\u7684\u98ce\u683c\u2014\u2014\u66f4\u9002\u5408\u65b0\u624b\u9605\u8bfb\uff0c\u540c\u65f6\u88ab\u201c\u9ad8\u4eba\u201d\u4e0d\u5c51\uff1a\u201c\u5199\u5f97\u592a\u7f57\u55e6\u5566\uff0c\u76f4\u63a5\u4e00\u53e5\u8bdd\u4e0d\u5c31\u5b8c\u4e8b\u5566\uff01\u201d\u8fd8\u65f6\u4e0d\u65f6\u6765\u4e00\u53e5\u201c\u9274\u5b9a\u5b8c\u6bd5\u201d\uff0c\u6069\uff0c\u633a\u9002\u5408\u53bb\u9a8c\u5c38<img decoding=\"async\" src=\"http:\/\/mat1.gtimg.com\/www\/mb\/images\/face\/98.gif\" align=\"absmiddle\">\u3002<\/p>\n<p>\u67ef\u91cc\u5316\u51fd\u6570\u662f\u6709\u4e00\u4e2a\u901a\u7528\u7684\u65b9\u6cd5\u7684\uff0c\u5728\u5b98\u5458\u90a3\u4e2a\u4f8b\u5b50(<code>currying()<\/code>\u65b9\u6cd5\u5c31\u662f)\u5176\u5b9e\u5df2\u7ecf\u5c55\u793a\u4e86\uff0c\u4e0d\u91cd\u590d\u5c55\u793a\uff0c\u81f3\u4e8e\u4ee3\u7801\u7684\u542b\u4e49\u561b\uff0c\u77e5\u8005\u81ea\u77e5\uff0c\u4e0d\u5570\u55e6\u3002<\/p>\n<p>\u597d\u4e45\u6ca1\u5728\u7ed3\u5c3e\u626f\u8fd9\u4e48\u591a\u4e71\u4e03\u516b\u7cdf\u7684\u4e1c\u897f\u4e86\uff0c\u626f\u5f97\u5fc3\u91cc\u50cf\u559d\u4e86\u5e38\u6da6\u8336\u822c\u8212\u7545\u3002\u672c\u6587\u5185\u5bb9\uff0c\u8fb9\u5b66\u4e60\u53d8\u6574\u7406\u7684\uff0cJS\u7684\u6982\u5ff5\u6211\u63a5\u89e6\u7684\u4e5f\u4e0d\u591a\uff0c\u6587\u4e2d\u9519\u8bef\u96be\u514d\uff0c\u6b22\u8fce\u6307\u6b63\uff0c\u6b22\u8fce\u4ea4\u6d41\uff0c\u4e92\u76f8\u5b66\u4e60\u3002<\/p>\n<p>\u672c\u6587\u4e3a\u539f\u521b\u6587\u7ae0\uff0c\u8f6c\u8f7d\u8bf7\u6ce8\u660e\u6765\u81ea<a href=\"http:\/\/www.zhangxinxu.com\/\">\u5f20\u946b\u65ed-\u946b\u7a7a\u95f4-\u946b\u751f\u6d3b<\/a>[<a href=\"http:\/\/www.zhangxinxu.com\/\">http:\/\/www.zhangxinxu.com<\/a>]<br \/>\n\u672c\u6587\u5730\u5740\uff1a<a href=\"http:\/\/www.zhangxinxu.com\/wordpress\/?p=3048\">http:\/\/www.zhangxinxu.com\/wordpress\/?p=3048<\/a><\/p>\n<p>\uff08\u672c\u7bc7\u5b8c\uff09<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u672c\u6587\u662fJS\u4e2d\u67ef\u91cc\u5316(currying)\u8fd9\u4e2a\u6982\u5ff5\u7684\u8bb2\u8ff0\uff0c\u901a\u8fc7\u65e5\u5e38\u6d45\u663e\u793a\u4f8b\u8bf4\u660e\uff0c\u6709\u591a\u591a\u6e90\u4ee3\u7801\u5c55\u793a\uff0c\u6ca1\u6709demo\uff0c\u563f\u563f\uff0c\u4e0d\u7ba1\u600e\u4e48\uff0c\u5e0c\u671b\u672c\u6587\u5185\u5bb9\u80fd\u591f\u5bf9\u4f60\u7684\u5b66\u4e60\u6709\u6240\u5e2e\u52a9\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[180],"tags":[782,1273,505,781],"_links":{"self":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts\/3048"}],"collection":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/comments?post=3048"}],"version-history":[{"count":0,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts\/3048\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/media?parent=3048"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/categories?post=3048"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/tags?post=3048"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}