{"id":1865,"date":"2024-11-10T13:57:40","date_gmt":"2024-11-10T05:57:40","guid":{"rendered":"https:\/\/fwq.ai\/blog\/1865\/"},"modified":"2024-11-10T13:57:40","modified_gmt":"2024-11-10T05:57:40","slug":"%e6%b5%8f%e8%a7%88%e5%99%a8%e3%80%81git-%e5%92%8c-node-js-%e6%89%a7%e8%a1%8c%e7%9b%b8%e5%90%8c%e4%bb%a3%e7%a0%81%e7%bb%93%e6%9e%9c%e4%b8%8d%e5%90%8c%ef%bc%8c%e5%8e%9f%e5%9b%a0%e4%bd%95%e5%9c%a8","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/1865\/","title":{"rendered":"\u6d4f\u89c8\u5668\u3001Git \u548c Node.js \u6267\u884c\u76f8\u540c\u4ee3\u7801\u7ed3\u679c\u4e0d\u540c\uff0c\u539f\u56e0\u4f55\u5728\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173060732374743.jpg\" class=\"aligncenter\" title=\"\u6d4f\u89c8\u5668\u3001Git \u548c Node.js \u6267\u884c\u76f8\u540c\u4ee3\u7801\u7ed3\u679c\u4e0d\u540c\uff0c\u539f\u56e0\u4f55\u5728\uff1f\u63d2\u56fe\" alt=\"\u6d4f\u89c8\u5668\u3001Git \u548c Node.js \u6267\u884c\u76f8\u540c\u4ee3\u7801\u7ed3\u679c\u4e0d\u540c\uff0c\u539f\u56e0\u4f55\u5728\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u6d4f\u89c8\u5668\u3001\u548cnode.js\u4e2d\u4ee3\u7801\u6267\u884c\u7ed3\u679c\u5dee\u5f02\u7684\u539f\u56e0<\/strong><\/p>\n<p>\u4ee5\u4e0b\u4ee3\u7801\u5728\u4e0d\u540c\u7684\u5e73\u53f0\u6267\u884c\u4f1a\u4ea7\u751f\u4e0d\u540c\u7684\u7ed3\u679c\uff1a<\/p>\n<pre>function foo() {\n  console.log(this.a);\n}\nvar a = 2;\nfoo();<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ul>\n<li> <strong>\u5728\u6d4f\u89c8\u5668\u4e2d\u8fd0\u884c\u6216\u5728git\u76f4\u63a5\u6267\u884c\uff1a<\/strong> \u7ed3\u679c\u4e3a2<\/li>\n<li> <strong>\u4fdd\u5b58\u5728\u72ec\u7acb\u7684js\u6587\u4ef6\u4e2d\uff0c\u4f7f\u7528node\u547d\u4ee4\u8c03\u7528\uff1a<\/strong> \u7ed3\u679c\u4e3aundefined<\/li>\n<\/ul>\n<p>\u539f\u56e0\u5728\u4e8enode.js\u4f7f\u7528\u4e86<strong>\u4e25\u683c\u6a21\u5f0f<\/strong>\uff0c\u800c\u6d4f\u89c8\u5668\u9ed8\u8ba4\u7684\u4e3a<strong>\u666e\u901a\u6a21\u5f0f<\/strong>\u3002<\/p>\n<p><strong>\u4e25\u683c\u6a21\u5f0f<\/strong>\u662f\u4e00\u79cd\u5f3a\u5236\u6267\u884c\u66f4\u4e25\u683c\u7684\u8bed\u6cd5\u548c\u8bed\u4e49\u89c4\u5219\u7684\u6a21\u5f0f\uff0c\u5b83\u5bf9\u5168\u5c40\u6709\u7740\u4e0d\u540c\u7684\u884c\u4e3a\u5b9a\u4e49\uff1a<\/p>\n<ul>\n<li>\u5728\u666e\u901a\u6a21\u5f0f\u4e0b\uff0c\u672a\u58f0\u660e\u7684\u53d8\u91cf\u88ab\u81ea\u52a8\u63d0\u5347\u5230\u5168\u5c40\u4f5c\u7528\u57df\u3002<\/li>\n<li>\u5728\u4e25\u683c\u6a21\u5f0f\u4e0b\uff0c\u672a\u58f0\u660e\u7684\u53d8\u91cf\u4f1a\u629b\u51fa\u9519\u8bef\u3002<\/li>\n<\/ul>\n<p>\u5728\u7ed9\u5b9a\u7684\u4ee3\u7801\u4e2d\uff0cthis\u5728\u4e25\u683c\u6a21\u5f0f\u4e0b\u6307\u5411\u5168\u5c40\u5bf9\u8c61\uff0c\u800c\u5168\u5c40\u5bf9\u8c61\u4e2d\u6ca1\u6709\u5b9a\u4e49a\u3002\u56e0\u6b64\uff0c\u5728\u4e25\u683c\u6a21\u5f0f\u4e0b\u8c03\u7528console.log(this.a)\u4f1a\u8f93\u51faundefined\u3002<\/p>\n<p>\u4e3a\u4e86\u5728\u6d4f\u89c8\u5668\u4e2d\u91cd\u73b0\u8be5\u884c\u4e3a\uff0c\u53ef\u4ee5\u5728\u811a\u672c\u4e0a\u6dfb\u52a0&#8221;use strict&#8221;\u8bed\u53e5\uff1a<\/p>\n<pre>\"use strict\";\n\nfunction foo() {\n  console.log(this.a);\n}\nvar a = 2;\nfoo();<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8fd9\u6837\uff0c\u4ee3\u7801\u5c06\u5728\u6d4f\u89c8\u5668\u4e2d\u8fd0\u884c\u65f6\uff0c\u4e5f\u4f1a\u8f93\u51faundefined\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u6d4f\u89c8\u5668\u3001Git \u548c Node.js \u6267\u884c\u76f8\u540c\u4ee3\u7801\u7ed3\u679c\u4e0d\u540c\uff0c\u539f\u56e0\u4f55\u5728\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6d4f\u89c8\u5668\u3001\u548cnode.js\u4e2d\u4ee3\u7801\u6267\u884c\u7ed3\u679c\u5dee\u5f02\u7684\u539f\u56e0 \u4ee5\u4e0b\u4ee3\u7801\u5728\u4e0d\u540c\u7684\u5e73\u53f0\u6267\u884c\u4f1a\u4ea7\u751f\u4e0d\u540c\u7684\u7ed3\u679c\uff1a function foo() { console.log(this.a); } var a = 2; foo(); \u767b\u5f55\u540e\u590d\u5236 \u5728\u6d4f\u89c8\u5668\u4e2d\u8fd0\u884c\u6216\u5728git\u76f4\u63a5\u6267\u884c\uff1a \u7ed3\u679c\u4e3a2 \u4fdd\u5b58\u5728\u72ec\u7acb\u7684js\u6587\u4ef6\u4e2d\uff0c\u4f7f\u7528node\u547d\u4ee4\u8c03\u7528\uff1a \u7ed3\u679c\u4e3aundefined \u539f\u56e0\u5728\u4e8enode.js\u4f7f\u7528\u4e86\u4e25\u683c\u6a21\u5f0f\uff0c\u800c\u6d4f\u89c8\u5668\u9ed8\u8ba4\u7684\u4e3a\u666e\u901a\u6a21\u5f0f\u3002 \u4e25\u683c\u6a21\u5f0f\u662f\u4e00\u79cd\u5f3a\u5236\u6267\u884c\u66f4\u4e25\u683c\u7684\u8bed\u6cd5\u548c\u8bed\u4e49\u89c4\u5219\u7684\u6a21\u5f0f\uff0c\u5b83\u5bf9\u5168\u5c40\u6709\u7740\u4e0d\u540c\u7684\u884c\u4e3a\u5b9a\u4e49\uff1a \u5728\u666e\u901a\u6a21\u5f0f\u4e0b\uff0c\u672a\u58f0\u660e\u7684\u53d8\u91cf\u88ab\u81ea\u52a8\u63d0\u5347\u5230\u5168\u5c40\u4f5c\u7528\u57df\u3002 \u5728\u4e25\u683c\u6a21\u5f0f\u4e0b\uff0c\u672a\u58f0\u660e\u7684\u53d8\u91cf\u4f1a\u629b\u51fa\u9519\u8bef\u3002 \u5728\u7ed9\u5b9a\u7684\u4ee3\u7801\u4e2d\uff0cthis\u5728\u4e25\u683c\u6a21\u5f0f\u4e0b\u6307\u5411\u5168\u5c40\u5bf9\u8c61\uff0c\u800c\u5168\u5c40\u5bf9\u8c61\u4e2d\u6ca1\u6709\u5b9a\u4e49a\u3002\u56e0\u6b64\uff0c\u5728\u4e25\u683c\u6a21\u5f0f\u4e0b\u8c03\u7528console.log(this.a)\u4f1a\u8f93\u51faundefined\u3002 \u4e3a\u4e86\u5728\u6d4f\u89c8\u5668\u4e2d\u91cd\u73b0\u8be5\u884c\u4e3a\uff0c\u53ef\u4ee5\u5728\u811a\u672c\u4e0a\u6dfb\u52a0&#8221;use strict&#8221;\u8bed\u53e5\uff1a &#8220;use strict&#8221;; function foo() { console.log(this.a); } var a = 2; foo(); \u767b\u5f55\u540e\u590d\u5236 \u8fd9\u6837\uff0c\u4ee3\u7801\u5c06\u5728\u6d4f\u89c8\u5668\u4e2d\u8fd0\u884c\u65f6\uff0c\u4e5f\u4f1a\u8f93\u51faundefined\u3002 \u4ee5\u4e0a\u5c31\u662f\u6d4f\u89c8\u5668\u3001Git \u548c Node.js \u6267\u884c\u76f8\u540c\u4ee3\u7801\u7ed3\u679c\u4e0d\u540c\uff0c\u539f\u56e0\u4f55\u5728\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-1865","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/1865","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=1865"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/1865\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=1865"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=1865"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=1865"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}