{"id":120,"date":"2024-12-08T19:06:27","date_gmt":"2024-12-08T11:06:27","guid":{"rendered":"https:\/\/www.laixuexila.com\/?p=120"},"modified":"2024-12-08T19:06:27","modified_gmt":"2024-12-08T11:06:27","slug":"js-%e8%83%bd%e5%90%a6%e6%94%af%e6%8c%81let-a-return-123-%e8%af%ad%e6%b3%95","status":"publish","type":"post","link":"https:\/\/www.laixuexila.com\/index.php\/2024\/12\/08\/js-%e8%83%bd%e5%90%a6%e6%94%af%e6%8c%81let-a-return-123-%e8%af%ad%e6%b3%95\/","title":{"rendered":"JS \u80fd\u5426\u652f\u6301let a = {return 123} \u8bed\u6cd5"},"content":{"rendered":"\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">\u7406\u8bba\u4e0a\uff0cJavaScript \u8bed\u6cd5\u5e76\u4e0d\u652f\u6301&nbsp;<code>let a = { return 123 }<\/code>&nbsp;\u8fd9\u79cd\u5199\u6cd5\u3002\u5176\u6839\u672c\u539f\u56e0\u662f JavaScript \u7684\u8bed\u6cd5\u89e3\u6790\u548c\u5173\u952e\u5b57\u7684\u4f7f\u7528\u89c4\u5219\uff0c\u7279\u522b\u662f\u5728\u5bf9\u8c61\u5b57\u9762\u91cf\u548c\u5757\u7ea7\u4f5c\u7528\u57df\u7684\u5b9a\u4e49\u4e4b\u95f4\u7684\u51b2\u7a81\u3002<\/p>\n<\/blockquote>\n<\/blockquote>\n\n\n\n<h3 class=\"wp-block-heading\">1. <strong>JavaScript \u8bed\u6cd5\u89c4\u5219<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728 JavaScript \u4e2d\uff0c<code>let a = { return 123 }<\/code> \u8fd9\u79cd\u8bed\u6cd5\u5e76\u4e0d\u88ab\u652f\u6301\uff0c\u6839\u672c\u539f\u56e0\u5728\u4e8e JavaScript \u7684 <strong>\u8bed\u6cd5\u89e3\u6790\u673a\u5236<\/strong>\uff0c\u7279\u522b\u662f\u5728<strong>\u5bf9\u8c61\u5b57\u9762\u91cf<\/strong>\u548c<strong>\u5173\u952e\u5b57\u4f7f\u7528\u89c4\u5219<\/strong>\u4e4b\u95f4\u7684\u51b2\u7a81\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">1.1 <strong>\u5bf9\u8c61\u5b57\u9762\u91cf\u8bed\u6cd5<\/strong><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">\u5bf9\u8c61\u5b57\u9762\u91cf\u662f JavaScript \u4e2d\u7528\u6765\u521b\u5efa\u5bf9\u8c61\u7684\u4e00\u79cd\u8bed\u6cd5\u3002\u5b83\u662f\u901a\u8fc7 <code>{}<\/code> \u6765\u8868\u793a\u7684\uff0c\u5e76\u4e14\u7531\u591a\u4e2a\u5c5e\u6027-\u503c\u5bf9\uff08\u952e\u503c\u5bf9\uff09\u7ec4\u6210\uff0c\u4f8b\u5982\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>let obj = { key: value };<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728\u89e3\u6790\u8fc7\u7a0b\u4e2d\uff0cJavaScript \u5f15\u64ce\u4f1a\u5c06 <code>{}<\/code> \u8bc6\u522b\u4e3a\u4e00\u4e2a\u5bf9\u8c61\u5b57\u9762\u91cf\u7684\u5f00\u59cb\uff0c\u56e0\u6b64\u9700\u8981\u6839\u636e\u8be5\u4e0a\u4e0b\u6587\u5bf9\u5176\u4e2d\u7684\u5185\u5bb9\u8fdb\u884c\u89e3\u6790\u3002\u5982\u679c\u5bf9\u8c61\u5b57\u9762\u91cf\u4e2d\u5305\u542b\u975e\u6cd5\u6216\u4e0d\u7b26\u5408\u8bed\u6cd5\u8981\u6c42\u7684\u5185\u5bb9\uff0c\u89e3\u6790\u5668\u4f1a\u629b\u51fa\u8bed\u6cd5\u9519\u8bef\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">1.2 <strong><code>return<\/code> \u5173\u952e\u5b57<\/strong><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\"><code>return<\/code> \u662f JavaScript \u4e2d\u7684\u4e00\u4e2a\u4fdd\u7559\u5173\u952e\u5b57\uff0c\u5176\u4e3b\u8981\u4f5c\u7528\u662f\u5728\u51fd\u6570\u4f53\u5185\u8fd4\u56de\u4e00\u4e2a\u503c\u3002\u5f53\u5f15\u64ce\u89e3\u6790\u5230 <code>return<\/code> \u65f6\uff0c\u901a\u5e38\u4f1a\u5c1d\u8bd5\u67e5\u770b\u5b83\u662f\u5426\u5904\u4e8e\u51fd\u6570\u4f53\u5185\u90e8\u3002\u5982\u679c\u4e0d\u5728\u51fd\u6570\u4f53\u5185\uff0c\u89e3\u6790\u5668\u4f1a\u4ea7\u751f\u8bed\u6cd5\u9519\u8bef\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u4f5c\u7528\u8303\u56f4<\/strong>\uff1a<code>return<\/code> \u53ea\u80fd\u51fa\u73b0\u5728\u51fd\u6570\u4f53\u5185\u90e8\uff0c\u7528\u4e8e\u4e2d\u65ad\u51fd\u6570\u6267\u884c\u5e76\u8fd4\u56de\u4e00\u4e2a\u503c\u3002<\/li>\n\n\n\n<li><strong>\u8bed\u6cd5\u7ea6\u675f<\/strong>\uff1a<code>return<\/code> \u8bed\u6cd5\u89c4\u5219\u660e\u786e\u8981\u6c42\u5b83\u53ea\u80fd\u5728\u51fd\u6570\u4f53\u4e2d\u4f7f\u7528\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">2. <strong>\u89e3\u6790\u51b2\u7a81\uff1a\u5bf9\u8c61\u5b57\u9762\u91cf\u4e0e\u5173\u952e\u5b57\u7684\u51b2\u7a81<\/strong><\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">2.1 <strong>\u5bf9\u8c61\u5b57\u9762\u91cf\u89e3\u6790<\/strong><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728 JavaScript \u4e2d\uff0c\u5f53 <code>{}<\/code> \u51fa\u73b0\u65f6\uff0c\u89e3\u6790\u5668\u9700\u8981\u5224\u65ad\u5b83\u662f <strong>\u4ee3\u7801\u5757<\/strong> \u8fd8\u662f <strong>\u5bf9\u8c61\u5b57\u9762\u91cf<\/strong>\u3002\u8fd9\u4e2a\u5224\u65ad\u4f9d\u636e\u4e3b\u8981\u4f9d\u8d56\u4e8e\u4e0a\u4e0b\u6587\u4fe1\u606f\u3002\u5982\u679c <code>{}<\/code> \u51fa\u73b0\u5728\u51fd\u6570\u6216\u63a7\u5236\u6d41\u8bed\u53e5\uff08\u5982 <code>if<\/code> \u6216 <code>for<\/code>\uff09\u4e2d\uff0c\u5b83\u4f1a\u88ab\u89e3\u6790\u4e3a\u4ee3\u7801\u5757\uff1b\u5982\u679c\u5b83\u51fa\u73b0\u5728\u8868\u8fbe\u5f0f\u4e2d\uff0c\u5e76\u4e14\u6ca1\u6709\u5173\u952e\u5b57\u6216\u8bed\u53e5\u7ed3\u6784\uff0c\u5b83\u4f1a\u88ab\u89e3\u6790\u4e3a\u5bf9\u8c61\u5b57\u9762\u91cf\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728 <code>let a = { return 123 }<\/code> \u4e2d\uff0c\u7531\u4e8e <code>return<\/code> \u662f\u4e00\u4e2a\u5173\u952e\u5b57\uff0cJavaScript \u5f15\u64ce\u4f1a\u5c06\u5176\u89c6\u4e3a\u65e0\u6548\u7684\u8bed\u6cd5\uff0c\u8ba4\u4e3a <code>return<\/code> \u4f5c\u4e3a\u5bf9\u8c61\u7684\u5c5e\u6027\u662f\u4e0d\u5141\u8bb8\u7684\uff0c\u8fdb\u800c\u5bfc\u81f4\u8bed\u6cd5\u89e3\u6790\u9519\u8bef\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">2.2 <strong>\u5173\u952e\u5b57\u7684\u7279\u6b8a\u8bed\u6cd5\u4f5c\u7528<\/strong><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\"><code>return<\/code> \u662f\u4e00\u4e2a\u5173\u952e\u5b57\uff0c\u5e76\u4e14\u5728 JavaScript \u4e2d\u5177\u6709\u7279\u6b8a\u7684\u8bed\u6cd5\u4f5c\u7528\u3002\u5177\u4f53\u800c\u8a00\uff0c<code>return<\/code> \u7528\u4e8e\u51fd\u6570\u5185\u90e8\u6807\u8bc6\u7ed3\u675f\u51fd\u6570\u6267\u884c\u5e76\u8fd4\u56de\u503c\u3002\u5f53\u5b83\u51fa\u73b0\u5728\u975e\u51fd\u6570\u4f53\u5185\u65f6\uff0c\u5b83\u4e0e\u5176\u4ed6\u8bed\u53e5\u4ea7\u751f\u51b2\u7a81\uff0c\u89e3\u6790\u5668\u65e0\u6cd5\u7406\u89e3\u5b83\u4f5c\u4e3a\u5bf9\u8c61\u5c5e\u6027\u6216\u503c\u7684\u542b\u4e49\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">3. <strong>\u4e3a\u4ec0\u4e48\u4e0d\u5141\u8bb8 <code>let a = { return 123 }<\/code><\/strong><\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">3.1 <strong>\u8bed\u6cd5\u89e3\u6790\u89c4\u5219<\/strong><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">JavaScript \u8bed\u8a00\u8bbe\u8ba1\u91c7\u7528\u4e86\u4e25\u683c\u7684\u8bed\u6cd5\u89c4\u5219\uff0c\u907f\u514d\u5173\u952e\u5b57\u5728\u4e0d\u9002\u5f53\u7684\u4e0a\u4e0b\u6587\u4e2d\u51fa\u73b0\uff0c\u8fd9\u6709\u52a9\u4e8e <strong>\u51cf\u5c11\u6b67\u4e49<\/strong>\u3002<code>return<\/code> \u7684\u8bed\u6cd5\u89c4\u5219\u662f\uff0c\u53ea\u6709\u5728 <strong>\u51fd\u6570\u4f53\u5185<\/strong>\u624d\u80fd\u4f7f\u7528\uff0c\u56e0\u6b64\u5728\u5bf9\u8c61\u5b57\u9762\u91cf\u4e2d\u51fa\u73b0 <code>return<\/code> \u4f1a\u5f15\u53d1 <strong>\u8bed\u6cd5\u89e3\u6790\u9519\u8bef<\/strong>\u3002\u89e3\u6790\u5668\u4f1a\u5c06 <code>return<\/code> \u89c6\u4e3a\u8bed\u53e5\uff0c\u800c\u4e0d\u662f\u5c5e\u6027\u6216\u503c\uff0c\u4ece\u800c\u5bfc\u81f4\u8bed\u6cd5\u9519\u8bef\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">3.2 <strong>\u5bf9\u8c61\u5b57\u9762\u91cf\u4e0e <code>return<\/code> \u51b2\u7a81<\/strong><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">\u5bf9\u8c61\u5b57\u9762\u91cf\u7684\u89e3\u6790\u662f\u57fa\u4e8e\u952e\u503c\u5bf9\u7684\uff0c\u6bcf\u4e2a\u952e\u90fd\u5e94\u8be5\u662f\u4e00\u4e2a\u5408\u6cd5\u7684\u6807\u8bc6\u7b26\u6216\u5b57\u7b26\u4e32\uff0c\u800c <code>return<\/code> \u662f\u5173\u952e\u5b57\uff0c\u5e76\u4e14\u5b83\u6ca1\u6709\u7c7b\u4f3c\u666e\u901a\u6807\u8bc6\u7b26\u7684\u4f5c\u7528\u3002\u5f53 <code>return<\/code> \u51fa\u73b0\u5728\u5bf9\u8c61\u5b57\u9762\u91cf\u4e2d\u65f6\uff0c\u89e3\u6790\u5668\u4f1a\u8bd5\u56fe\u5c06\u5b83\u89e3\u6790\u4e3a\u4e00\u4e2a\u975e\u6cd5\u7684\u5bf9\u8c61\u5c5e\u6027\uff0c\u4ece\u800c\u629b\u51fa\u9519\u8bef\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4f8b\u5982\uff0c<code>let a = { return: 123 }<\/code> \u4e5f\u4f1a\u5bfc\u81f4\u9519\u8bef\uff0c\u56e0\u4e3a <code>return<\/code> \u4f5c\u4e3a\u5bf9\u8c61\u7684\u5c5e\u6027\u540d\u4f1a\u5f15\u8d77\u8bed\u6cd5\u6b67\u4e49\uff0c\u65e0\u6cd5\u88ab\u89c6\u4e3a\u6709\u6548\u7684\u5c5e\u6027\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">4. <strong>\u603b\u7ed3<\/strong><\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>JavaScript \u8bed\u6cd5\u89e3\u6790\u673a\u5236<\/strong>\uff1aJavaScript \u5f15\u64ce\u6839\u636e\u4e0a\u4e0b\u6587\u51b3\u5b9a <code>{}<\/code> \u662f\u8868\u793a\u4ee3\u7801\u5757\u8fd8\u662f\u5bf9\u8c61\u5b57\u9762\u91cf\u3002<code>return<\/code> \u662f\u4e00\u4e2a\u5177\u6709\u7279\u6b8a\u610f\u4e49\u7684\u5173\u952e\u5b57\uff0c\u53ea\u80fd\u5728\u51fd\u6570\u4f53\u5185\u4f7f\u7528\uff0c\u56e0\u6b64\u5b83\u4e0d\u80fd\u4f5c\u4e3a\u5bf9\u8c61\u5b57\u9762\u91cf\u7684\u5c5e\u6027\u6216\u503c\u3002<\/li>\n\n\n\n<li><strong>\u5173\u952e\u5b57\u4f7f\u7528\u7ea6\u675f<\/strong>\uff1a<code>return<\/code> \u7684\u8bed\u6cd5\u89c4\u5219\u660e\u786e\u89c4\u5b9a\u5b83\u53ea\u80fd\u5728\u51fd\u6570\u5185\u90e8\u4f5c\u4e3a\u8bed\u53e5\u4f7f\u7528\u3002\u5c1d\u8bd5\u5c06\u5176\u7528\u4f5c\u5bf9\u8c61\u5c5e\u6027\u6216\u8868\u8fbe\u5f0f\u4e2d\u7684\u4e00\u90e8\u5206\u4f1a\u5bfc\u81f4\u8bed\u6cd5\u9519\u8bef\u3002<\/li>\n\n\n\n<li><strong>\u8bed\u6cd5\u6b67\u4e49\u4e0e\u89e3\u6790\u5668\u7684\u9650\u5236<\/strong>\uff1a\u5141\u8bb8 <code>return<\/code> \u5728\u5bf9\u8c61\u5b57\u9762\u91cf\u4e2d\u4f7f\u7528\u4f1a\u5bfc\u81f4\u8bed\u6cd5\u89e3\u6790\u7684\u6b67\u4e49\u3002\u4e3a\u4e86\u907f\u514d\u8fd9\u79cd\u6b67\u4e49\u5e76\u4fdd\u8bc1\u4ee3\u7801\u7684\u6e05\u6670\u6027\u548c\u4e00\u81f4\u6027\uff0cJavaScript \u7981\u6b62\u4e86\u8fd9\u79cd\u7528\u6cd5\u3002<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>1. JavaScript \u8bed\u6cd5\u89c4\u5219 \u5728 JavaScript \u4e2d\uff0clet a = { return 123  [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[46],"tags":[],"class_list":["post-120","post","type-post","status-publish","format-standard","hentry","category-javascript"],"_links":{"self":[{"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/posts\/120","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/comments?post=120"}],"version-history":[{"count":1,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/posts\/120\/revisions"}],"predecessor-version":[{"id":122,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/posts\/120\/revisions\/122"}],"wp:attachment":[{"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/media?parent=120"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/categories?post=120"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/tags?post=120"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}