{"id":4052,"date":"2024-11-10T14:30:01","date_gmt":"2024-11-10T06:30:01","guid":{"rendered":"https:\/\/fwq.ai\/blog\/4052\/"},"modified":"2024-11-10T14:30:01","modified_gmt":"2024-11-10T06:30:01","slug":"%e5%a6%82%e4%bd%95%e5%b0%86-javascript-%e4%b8%ad%e7%9a%84-console-log-%e8%be%93%e5%87%ba%e5%ad%98%e5%82%a8%e5%88%b0%e6%95%b0%e7%bb%84%e6%88%96%e5%af%b9%e8%b1%a1%e4%b8%ad%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/4052\/","title":{"rendered":"\u5982\u4f55\u5c06 JavaScript \u4e2d\u7684 console.log() \u8f93\u51fa\u5b58\u50a8\u5230\u6570\u7ec4\u6216\u5bf9\u8c61\u4e2d\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173121768495572.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u5c06 JavaScript \u4e2d\u7684 console.log() \u8f93\u51fa\u5b58\u50a8\u5230\u6570\u7ec4\u6216\u5bf9\u8c61\u4e2d\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u5c06 JavaScript \u4e2d\u7684 console.log() \u8f93\u51fa\u5b58\u50a8\u5230\u6570\u7ec4\u6216\u5bf9\u8c61\u4e2d\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u63a7\u5236\u53f0\u8f93\u51fa\u6536\u96c6\u6280\u5de7\uff1a\u5b58\u50a8 console.log() \u8f93\u51fa\u5230\u6570\u7ec4\u6216\u5bf9\u8c61<\/strong><\/p>\n<p>\u5728 javascript \u5f00\u53d1\u4e2d\uff0c\u5229\u7528 console.log() \u51fd\u6570\u5728\u63a7\u5236\u53f0\u4e2d\u6253\u5370\u4fe1\u606f\u975e\u5e38\u65b9\u4fbf\u3002\u4f46\u662f\uff0c\u5982\u679c\u60a8\u60f3\u6536\u96c6\u8fd9\u4e9b\u6253\u5370\u4fe1\u606f\u4ee5\u4f9b\u5c06\u6765\u4f7f\u7528\uff0c\u600e\u4e48\u529e\u5462\uff1f\u672c\u6587\u5c06\u4ecb\u7ecd\u5982\u4f55\u5c06 console.log() \u8f93\u51fa\u5b58\u50a8\u5230\u6570\u7ec4\u6216\u5bf9\u8c61\u4e2d\u3002<\/p>\n<p><strong>\u65b9\u6cd5\u4e00\uff1a\u4f7f\u7528\u6570\u7ec4<\/strong><\/p>\n<p>\u521b\u5efa\u4e00\u4e2a\u5168\u5c40\u53d8\u91cf\u6570\u7ec4\uff0c\u4f8b\u5982 let output = []\u3002\u7136\u540e\uff0c\u5728 console.log(temp) \u8f93\u51fa\u8bed\u53e5\u540e\u9762\u6dfb\u52a0\u4e00\u884c output.push(temp)\u3002\u8fd9\u6837\uff0c\u6bcf\u6b21\u8c03\u7528 console.log(temp) \u65f6\uff0ctemp \u7684\u503c\u90fd\u4f1a\u6dfb\u52a0\u5230\u8f93\u51fa\u6570\u7ec4\u4e2d\u3002<\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<p><strong>\u65b9\u6cd5\u4e8c\uff1a\u4f7f\u7528\u5bf9\u8c61<\/strong><\/p>\n<p>\u540c\u6837\uff0c\u521b\u5efa\u4e00\u4e2a\u5168\u5c40\u53d8\u91cf\u5bf9\u8c61\uff0c\u4f8b\u5982 let output = {}\u3002\u7136\u540e\uff0c\u5728 console.log(temp) \u8f93\u51fa\u8bed\u53e5\u540e\u9762\u6dfb\u52a0\u4e00\u884c output.push(&#8216;temp&#8217;, temp)\u3002\u8fd9\u6837\uff0ctemp \u7684\u503c\u5c06\u4f5c\u4e3a\u8be5\u5bf9\u8c61\u7684\u5c5e\u6027\u5b58\u50a8\uff0c\u5176\u540d\u79f0\u4e3a &#8220;temp&#8221;\u3002<\/p>\n<p><strong>\u4f7f\u7528\u573a\u666f<\/strong><\/p>\n<p>\u8fd9\u4e9b\u65b9\u6cd5\u53ef\u7528\u4e8e\u5404\u79cd\u573a\u666f\uff0c\u4f8b\u5982\uff1a<\/p>\n<ul>\n<li>\u6536\u96c6\u8c03\u8bd5\u4fe1\u606f\u4ee5\u8fdb\u884c\u540e\u671f\u5206\u6790<\/li>\n<li>\u6355\u83b7\u72b6\u6001\u66f4\u6539\u4ee5\u7528\u4e8e\u72b6\u6001\u7ba1\u7406<\/li>\n<li>\u5c06\u8f93\u51fa\u5b58\u50a8\u5230\u6587\u672c\u6587\u4ef6\u4e2d\u8fdb\u884c\u8bb0\u5f55<\/li>\n<\/ul>\n<p><strong>\u4ee3\u7801\u793a\u4f8b<\/strong><\/p>\n<p><strong>\u6570\u7ec4<\/strong><\/p>\n<pre>let output = [];\nconsole.log(temp);\noutput.push(temp);<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u5bf9\u8c61<\/strong><\/p>\n<pre>let output = {};\nconsole.log(temp);\noutput.temp = temp;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u901a\u8fc7\u4f7f\u7528\u8fd9\u4e9b\u65b9\u6cd5\uff0c\u60a8\u53ef\u4ee5\u8f7b\u677e\u5730\u6536\u96c6\u548c\u7ba1\u7406 console.log() \u8f93\u51fa\uff0c\u4f7f\u5176\u5728\u60a8\u7684 javascript \u5e94\u7528\u7a0b\u5e8f\u4e2d\u5b9e\u73b0\u66f4\u9ad8\u7ea7\u529f\u80fd\u6210\u4e3a\u53ef\u80fd\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u5c06 JavaScript \u4e2d\u7684 console.log() \u8f93\u51fa\u5b58\u50a8\u5230\u6570\u7ec4\u6216\u5bf9\u8c61\u4e2d\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>\u63a7\u5236\u53f0\u8f93\u51fa\u6536\u96c6\u6280\u5de7\uff1a\u5b58\u50a8 console.log() \u8f93\u51fa\u5230\u6570\u7ec4\u6216\u5bf9\u8c61 \u5728 javascript \u5f00\u53d1\u4e2d\uff0c\u5229\u7528 console.log() \u51fd\u6570\u5728\u63a7\u5236\u53f0\u4e2d\u6253\u5370\u4fe1\u606f\u975e\u5e38\u65b9\u4fbf\u3002\u4f46\u662f\uff0c\u5982\u679c\u60a8\u60f3\u6536\u96c6\u8fd9\u4e9b\u6253\u5370\u4fe1\u606f\u4ee5\u4f9b\u5c06\u6765\u4f7f\u7528\uff0c\u600e\u4e48\u529e\u5462\uff1f\u672c\u6587\u5c06\u4ecb\u7ecd\u5982\u4f55\u5c06 console.log() \u8f93\u51fa\u5b58\u50a8\u5230\u6570\u7ec4\u6216\u5bf9\u8c61\u4e2d\u3002 \u65b9\u6cd5\u4e00\uff1a\u4f7f\u7528\u6570\u7ec4 \u521b\u5efa\u4e00\u4e2a\u5168\u5c40\u53d8\u91cf\u6570\u7ec4\uff0c\u4f8b\u5982 let output = []\u3002\u7136\u540e\uff0c\u5728 console.log(temp) \u8f93\u51fa\u8bed\u53e5\u540e\u9762\u6dfb\u52a0\u4e00\u884c output.push(temp)\u3002\u8fd9\u6837\uff0c\u6bcf\u6b21\u8c03\u7528 console.log(temp) \u65f6\uff0ctemp \u7684\u503c\u90fd\u4f1a\u6dfb\u52a0\u5230\u8f93\u51fa\u6570\u7ec4\u4e2d\u3002 \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b \u65b9\u6cd5\u4e8c\uff1a\u4f7f\u7528\u5bf9\u8c61 \u540c\u6837\uff0c\u521b\u5efa\u4e00\u4e2a\u5168\u5c40\u53d8\u91cf\u5bf9\u8c61\uff0c\u4f8b\u5982 let output = {}\u3002\u7136\u540e\uff0c\u5728 console.log(temp) \u8f93\u51fa\u8bed\u53e5\u540e\u9762\u6dfb\u52a0\u4e00\u884c output.push(&#8216;temp&#8217;, temp)\u3002\u8fd9\u6837\uff0ctemp \u7684\u503c\u5c06\u4f5c\u4e3a\u8be5\u5bf9\u8c61\u7684\u5c5e\u6027\u5b58\u50a8\uff0c\u5176\u540d\u79f0\u4e3a &#8220;temp&#8221;\u3002 \u4f7f\u7528\u573a\u666f \u8fd9\u4e9b\u65b9\u6cd5\u53ef\u7528\u4e8e\u5404\u79cd\u573a\u666f\uff0c\u4f8b\u5982\uff1a \u6536\u96c6\u8c03\u8bd5\u4fe1\u606f\u4ee5\u8fdb\u884c\u540e\u671f\u5206\u6790 \u6355\u83b7\u72b6\u6001\u66f4\u6539\u4ee5\u7528\u4e8e\u72b6\u6001\u7ba1\u7406 \u5c06\u8f93\u51fa\u5b58\u50a8\u5230\u6587\u672c\u6587\u4ef6\u4e2d\u8fdb\u884c\u8bb0\u5f55 \u4ee3\u7801\u793a\u4f8b \u6570\u7ec4 let output = []; console.log(temp); output.push(temp); \u767b\u5f55\u540e\u590d\u5236 \u5bf9\u8c61 let output = {}; console.log(temp); [&hellip;]<\/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-4052","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/4052","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=4052"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/4052\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=4052"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=4052"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=4052"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}