{"id":4541,"date":"2023-08-27T23:47:39","date_gmt":"2023-08-27T15:47:39","guid":{"rendered":"https:\/\/blog.odjbinail.cn\/?p=4541"},"modified":"2023-08-27T23:57:26","modified_gmt":"2023-08-27T15:57:26","slug":"%e4%b8%a4%e4%b8%aa%e7%9b%b8%e7%ad%89%e7%9a%84%e6%95%b0%e7%bb%84%ef%bc%8c%e4%bf%ae%e6%94%b9%e5%85%b6%e4%b8%ad%e4%b8%80%e4%b8%aa%e6%95%b0%e7%bb%84%e6%80%8e%e4%b9%88%e5%81%9a%e5%88%b0%e4%b8%8d%e6%94%b9","status":"publish","type":"post","link":"https:\/\/blog.odjbinail.cn\/?p=4541","title":{"rendered":"\u4e24\u4e2a\u76f8\u7b49\u7684\u6570\u7ec4\uff0c\u4fee\u6539\u5176\u4e2d\u4e00\u4e2a\u6570\u7ec4\u600e\u4e48\u505a\u5230\u4e0d\u6539\u53d8\u53e6\u5916\u4e00\u4e2a\u6570\u7ec4\uff1f"},"content":{"rendered":"<h3>\u793a\u4f8b\u6570\u7ec4<\/h3>\n<p>\u73b0\u5728\u6709\u4e24\u4e2a\u6570\u7ec4<\/p>\n<pre class=\"prettyprint linenums\" ><code>let arrA = [1, 2, 3];\nlet arrB = arrA;\nconsole.log(arrA); \/\/ [1, 2, 3]\nconsole.log(arrB); \/\/ [1, 2, 3]<\/code><\/pre>\n<ul>\n<li>\u5f53\u4fee\u6539\u5176\u4e2d\u4e00\u4e2a\u6570\u7ec4, \u53e6\u4e00\u4e2a\u6570\u7ec4\u8ddf\u7740\u53d8<\/li>\n<\/ul>\n<pre class=\"prettyprint linenums\" ><code>arrA[0] = 10;\nconsole.log(arrA); \/\/ [10, 2, 3]\nconsole.log(arrB); \/\/ [10, 2, 3]<\/code><\/pre>\n<p><strong>\u5bfc\u81f4\u4e24\u4e2a\u6570\u7ec4\u76f8\u4e92\u5f71\u54cd\u7684\u539f\u56e0\uff1a<\/strong><\/p>\n<ul>\n<li>js \u4e2d array \u662f\u5f15\u7528\u7c7b\u578b\uff0c\u4e5f\u5c31\u662f arrA \u548c arrB \u7684\u539f\u6570\u636e\u5b58\u50a8\u5730\u5740\u662f\u4e00\u6837\u7684\uff0carrA \u548c arrB \u90fd\u662f\u5bf9\u539f\u6570\u636e\u7684\u5f15\u7528\uff0c\u6240\u4ee5\u4fee\u6539\u5176\u4e2d\u4e00\u4e2a\uff0c\u53e6\u4e00\u4e2a\u4e5f\u4f1a\u6539\u53d8\u3002<\/li>\n<li>\u8fd9\u5c31\u597d\u50cf\u662f\u73b0\u5728\u6709\u4e00\u4e2a\u623f\u95f4\uff0c\u4e24\u6247\u95e8\uff0cAB \u4e24\u4eba\u5206\u522b\u4ece\u4e0d\u540c\u7684\u95e8\u8fdb\u53bb\u6240\u770b\u5230\u7684\u7684\u623f\u95f4\u662f\u4e00\u6837\u7684\uff0c\u6b64\u65f6 A \u62ff\u8d70\u4e00\u4e2a\u82f9\u679c\uff0cB \u4f1a\u770b\u5230\u623f\u95f4\u91cc\u5c11\u4e86\u4e00\u4e2a\u82f9\u679c\uff1bB \u4ece\u5916\u9762\u5e26\u4e86\u4e00\u74f6\u996e\u6599\u56de\u5230\u623f\u95f4\uff0cA \u4e5f\u4f1a\u770b\u5230\u8fd9\u4e2a\u623f\u95f4\u591a\u4e86\u4e00\u74f6\u996e\u6599\u3002<\/li>\n<\/ul>\n<p>\u90a3\u4e48\u4e0a\u9762\u4e24\u4e2a\u76f8\u7b49\u7684\u6570\u7ec4\uff0c\u4fee\u6539\u5176\u4e2d\u4e00\u4e2a\u600e\u4e48\u505a\u5230\u4e0d\u6539\u53d8\u53e6\u5916\u4e00\u4e2a\u5462\uff1f<\/p>\n<h3>\u89e3\u51b3\u529e\u6cd5: (\u8fd9\u91cc\u53ea\u5c55\u793a\u4e2a\u4eba uniapp \u9879\u76ee\u4e2d\u4f7f\u7528\u7684\u65b9\u6cd5)<\/h3>\n<p>concat()\u7528\u4e8e\u8fde\u63a5\u4e24\u4e2a\u6216\u591a\u4e2a\u6570\u7ec4\u3002\uff08\u8be5\u65b9\u6cd5\u4e0d\u4f1a\u6539\u53d8\u73b0\u6709\u7684\u6570\u7ec4\uff0c\u800c\u4ec5\u4ec5\u4f1a\u8fd4\u56de\u88ab\u8fde\u63a5\u6570\u7ec4\u7684\u4e00\u4e2a\u526f\u672c\uff09<\/p>\n<pre class=\"prettyprint linenums\" ><code>let arrA = [1, 2, 3];\nlet arrB = [].concat(arrA);\nconsole.log(arrA,arrB);  \/\/ [1, 2, 3],[1, 2, 3]\n\/\/\u5f53\u4fee\u6539\u5176\u4e2d\u4e00\u4e2a\u6570\u7ec4, \u53e6\u4e00\u4e2a\u6570\u7ec4\u4e0d\u53d8\narrA.splice(0,1);\nconsole.log(arrA,arrB);  \/\/ [2, 3],[1, 2, 3]<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u793a\u4f8b\u6570\u7ec4 \u73b0\u5728\u6709\u4e24\u4e2a\u6570\u7ec4 let arrA = [1, 2, 3]; let arrB = arrA; con [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4541","post","type-post","status-publish","format-standard","hentry","category-1"],"_links":{"self":[{"href":"https:\/\/blog.odjbinail.cn\/index.php?rest_route=\/wp\/v2\/posts\/4541","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.odjbinail.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.odjbinail.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.odjbinail.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.odjbinail.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4541"}],"version-history":[{"count":3,"href":"https:\/\/blog.odjbinail.cn\/index.php?rest_route=\/wp\/v2\/posts\/4541\/revisions"}],"predecessor-version":[{"id":4544,"href":"https:\/\/blog.odjbinail.cn\/index.php?rest_route=\/wp\/v2\/posts\/4541\/revisions\/4544"}],"wp:attachment":[{"href":"https:\/\/blog.odjbinail.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4541"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.odjbinail.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4541"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.odjbinail.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4541"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}