{"id":52649,"date":"2024-12-03T08:51:54","date_gmt":"2024-12-03T00:51:54","guid":{"rendered":"https:\/\/fwq.ai\/blog\/52649\/"},"modified":"2024-12-03T08:51:54","modified_gmt":"2024-12-03T00:51:54","slug":"%e5%ad%97%e7%ac%a6%e4%b8%b2%e4%b8%8e%e5%ad%97%e7%ac%a6%e4%b8%b2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/52649\/","title":{"rendered":"\u5b57\u7b26\u4e32\u4e0e\u5b57\u7b26\u4e32"},"content":{"rendered":"<p><b><\/b>     <\/p>\n<h1>\u5b57\u7b26\u4e32\u4e0e\u5b57\u7b26\u4e32<\/h1>\n<p><span style=\"cursor: pointer\"><i><\/i>\u6536\u85cf<\/span>    <\/p>\n<p><span style=\"font-size: 15px\">\u5b66\u4e60\u77e5\u8bc6\u8981\u5584\u4e8e\u601d\u8003\uff0c\u601d\u8003\uff0c\u518d\u601d\u8003\uff01\u4eca\u5929\u7c73\u4e91\u5c0f\u7f16\u5c31\u7ed9\u5927\u5bb6\u5e26\u6765<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u300a\u5b57\u7b26\u4e32\u4e0e\u5b57\u7b26\u4e32\u300b<\/span>\uff0c\u4ee5\u4e0b\u5185\u5bb9\u4e3b\u8981\u5305\u542b<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><\/span>\u7b49\u77e5\u8bc6\u70b9\uff0c\u5982\u679c\u4f60\u6b63\u5728\u5b66\u4e60\u6216\u51c6\u5907\u5b66\u4e60<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u6587\u7ae0<\/span>\uff0c\u5c31\u90fd\u4e0d\u8981\u9519\u8fc7\u672c\u6587\u5566~\u8ba9\u6211\u4eec\u4e00\u8d77\u6765\u770b\u770b\u5427\uff0c\u80fd\u5e2e\u52a9\u5230\u4f60\u5c31\u66f4\u597d\u4e86\uff01<\/span><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241122\/1732251829674010b52864e.jpg\" class=\"aligncenter\" title=\"\u5b57\u7b26\u4e32\u4e0e\u5b57\u7b26\u4e32\u63d2\u56fe\" alt=\"\u5b57\u7b26\u4e32\u4e0e\u5b57\u7b26\u4e32\u63d2\u56fe\" \/><\/p>\n<h2> \u7ec6\u7ef3 <\/h2>\n<p><strong>\u5c0f\u5199\u5b57\u7b26\u4e32<\/strong>\u662fjavascript\u4e2d\u7684<em>\u539f\u59cb\u6570\u636e\u7c7b\u578b<\/em>\u3002<\/p>\n<p>\u7528\u8fd9\u79cd\u7c7b\u578b\u521b\u5efa\u7684\u5b57\u7b26\u4e32\u4e0d\u662f\u5bf9\u8c61\uff0c\u4f46 javascript \u4f1a\u81ea\u52a8\u7528 string \u5bf9\u8c61\u5305\u88c5\u5b83\u4eec\uff08\u8fd9\u79f0\u4e3a\u201c\u88c5\u7bb1\u201d\uff09\u3002<\/p>\n<pre>let imastring = \"hello\";\nconsole.log(typeof imastring); \/\/ \"string\"\n<\/pre>\n<hr>\n<h2> \u7ec6\u7ef3 <\/h2>\n<p><strong>\u5927\u5199\u5b57\u7b26\u4e32<\/strong> \u662f\u4e00\u4e2a<em>\u6784\u9020\u51fd\u6570<\/em>\uff0c\u7528\u4e8e\u521b\u5efa string \u5bf9\u8c61\uff0c\u5373\u5b57\u7b26\u4e32\u57fa\u5143\u7684\u5bf9\u8c61\u5305\u88c5\u5668\u3002<\/p>\n<p>\u5f53\u60a8\u5c06 string \u6784\u9020\u51fd\u6570\u4e0e new \u4e00\u8d77\u4f7f\u7528\u65f6\uff0c\u60a8\u5c06\u5f97\u5230\u4e00\u4e2a string \u5bf9\u8c61\u800c\u4e0d\u662f\u539f\u59cb\u5b57\u7b26\u4e32<\/p>\n<p>\u5b57\u7b26\u4e32\u5bf9\u8c61\u4e0d\u662f\u5fc5\u9700\u7684\uff0c\u9664\u975e\u60a8\u9700\u8981\u660e\u786e\u5730\u5c06\u5b83\u4eec\u7528\u4f5c\u5bf9\u8c61\u3002<\/p>\n<pre>let imAStringObject = new String(\"hello\");\nconsole.log(typeof imAStringObject); \/\/ \"object\"\n<\/pre>\n<hr>\n<h2> \u5dee\u5f02 <\/h2>\n<table>\n<thead>\n<tr>\n<th><\/th>\n<th>string<\/th>\n<th>string<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>type<\/td>\n<td>primitive<\/td>\n<td>object<\/td>\n<\/tr>\n<tr>\n<td>memory<\/td>\n<td>lightweight and stored by value<\/td>\n<td>heavyweight, stored as object<\/td>\n<\/tr>\n<tr>\n<td>methods<\/td>\n<td>get converted to string object temporarily<\/td>\n<td>has access to string methods like .charat() <\/td>\n<\/tr>\n<tr>\n<td>comparing values<\/td>\n<td>by values<\/td>\n<td>by reference<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr>\n<h2> \u4ec0\u4e48\u65f6\u5019\u4f7f\u7528\u5b57\u7b26\u4e32\/\u5b57\u7b26\u4e32\uff1f <\/h2>\n<p><strong>\u51e0\u4e4e\u5728\u6240\u6709\u60c5\u51b5\u4e0b\u90fd\u4f7f\u7528\u5b57\u7b26\u4e32<\/strong>\uff08\u539f\u59cb\uff09\u3002\u5b83\u66f4\u9ad8\u6548\u3001\u66f4\u7b80\u5355\uff0c\u5e76\u4e14 javascript \u5728\u9700\u8981\u65f6\u81ea\u52a8\u63d0\u4f9b\u65b9\u6cd5\u3002<\/p>\n<p><strong>\u4ec5\u5f53\u60a8\u7279\u522b\u9700\u8981\u5177\u6709\u9644\u52a0\u5c5e\u6027\u7684\u5bf9\u8c61\u6216\u60f3\u8981\u4f7f\u7528 instanceof \u68c0\u67e5\u65f6\u624d\u4f7f\u7528 string<\/strong>\uff08\u5bf9\u8c61\uff09\uff0c\u5c3d\u7ba1\u8fd9\u5728\u5b9e\u8df5\u4e2d\u5f88\u5c11\u89c1\u3002<\/p>\n<hr>\n<p>\u5c31\u662f\u8fd9\u6837\uff01\u611f\u8c22\u60a8\u9605\u8bfb\u672c\u6587\u3002\u4e0b\u6b21\u89c1\uff01<\/p>\n<p>\u7ec8\u4e8e\u4ecb\u7ecd\u5b8c\u5566\uff01\u5c0f\u4f19\u4f34\u4eec\uff0c\u8fd9\u7bc7\u5173\u4e8e\u300a\u5b57\u7b26\u4e32\u4e0e\u5b57\u7b26\u4e32\u300b\u7684\u4ecb\u7ecd\u5e94\u8be5\u8ba9\u4f60\u6536\u83b7\u591a\u591a\u4e86\u5427\uff01\u6b22\u8fce\u5927\u5bb6\u6536\u85cf\u6216\u5206\u4eab\u7ed9\u66f4\u591a\u9700\u8981\u5b66\u4e60\u7684\u670b\u53cb\u5427~\u7c73\u4e91\u516c\u4f17\u53f7\u4e5f\u4f1a\u53d1\u5e03\u6587\u7ae0\u76f8\u5173\u77e5\u8bc6\uff0c\u5feb\u6765\u5173\u6ce8\u5427\uff01<\/p>\n<p>      \u7248\u672c\u58f0\u660e \u672c\u6587\u8f6c\u8f7d\u4e8e\uff1adev.to \u5982\u6709\u4fb5\u72af\uff0c\u8bf7\u8054\u7cfb\u5220\u9664    <\/p>\n<dl>\n<dt><\/dt>\n<dd>\n   Win11\u63d0\u793a\u8131\u673a\u72b6\u6001\u600e\u4e48\u529e Win11\u63d0\u793a\u8131\u673a\u72b6\u6001\u7684\u89e3\u51b3\u65b9\u6cd5\n <\/dd>\n<\/dl>\n","protected":false},"excerpt":{"rendered":"<p>\u5b57\u7b26\u4e32\u4e0e\u5b57\u7b26\u4e32 \u6536\u85cf \u5b66\u4e60\u77e5\u8bc6\u8981\u5584\u4e8e\u601d\u8003\uff0c\u601d\u8003\uff0c\u518d\u601d\u8003\uff01\u4eca\u5929\u7c73\u4e91\u5c0f\u7f16\u5c31\u7ed9\u5927\u5bb6\u5e26\u6765\u300a\u5b57\u7b26\u4e32\u4e0e\u5b57\u7b26\u4e32\u300b\uff0c\u4ee5\u4e0b\u5185\u5bb9\u4e3b\u8981\u5305\u542b\u7b49\u77e5\u8bc6\u70b9\uff0c\u5982\u679c\u4f60\u6b63\u5728\u5b66\u4e60\u6216\u51c6\u5907\u5b66\u4e60\u6587\u7ae0\uff0c\u5c31\u90fd\u4e0d\u8981\u9519\u8fc7\u672c\u6587\u5566~\u8ba9\u6211\u4eec\u4e00\u8d77\u6765\u770b\u770b\u5427\uff0c\u80fd\u5e2e\u52a9\u5230\u4f60\u5c31\u66f4\u597d\u4e86\uff01 \u7ec6\u7ef3 \u5c0f\u5199\u5b57\u7b26\u4e32\u662fjavascript\u4e2d\u7684\u539f\u59cb\u6570\u636e\u7c7b\u578b\u3002 \u7528\u8fd9\u79cd\u7c7b\u578b\u521b\u5efa\u7684\u5b57\u7b26\u4e32\u4e0d\u662f\u5bf9\u8c61\uff0c\u4f46 javascript \u4f1a\u81ea\u52a8\u7528 string \u5bf9\u8c61\u5305\u88c5\u5b83\u4eec\uff08\u8fd9\u79f0\u4e3a\u201c\u88c5\u7bb1\u201d\uff09\u3002 let imastring = &#8220;hello&#8221;; console.log(typeof imastring); \/\/ &#8220;string&#8221; \u7ec6\u7ef3 \u5927\u5199\u5b57\u7b26\u4e32 \u662f\u4e00\u4e2a\u6784\u9020\u51fd\u6570\uff0c\u7528\u4e8e\u521b\u5efa string \u5bf9\u8c61\uff0c\u5373\u5b57\u7b26\u4e32\u57fa\u5143\u7684\u5bf9\u8c61\u5305\u88c5\u5668\u3002 \u5f53\u60a8\u5c06 string \u6784\u9020\u51fd\u6570\u4e0e new \u4e00\u8d77\u4f7f\u7528\u65f6\uff0c\u60a8\u5c06\u5f97\u5230\u4e00\u4e2a string \u5bf9\u8c61\u800c\u4e0d\u662f\u539f\u59cb\u5b57\u7b26\u4e32 \u5b57\u7b26\u4e32\u5bf9\u8c61\u4e0d\u662f\u5fc5\u9700\u7684\uff0c\u9664\u975e\u60a8\u9700\u8981\u660e\u786e\u5730\u5c06\u5b83\u4eec\u7528\u4f5c\u5bf9\u8c61\u3002 let imAStringObject = new String(&#8220;hello&#8221;); console.log(typeof imAStringObject); \/\/ &#8220;object&#8221; \u5dee\u5f02 string string type primitive object memory lightweight and stored by value heavyweight, stored as [&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-52649","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/52649","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=52649"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/52649\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=52649"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=52649"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=52649"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}