{"id":170566,"date":"2024-05-08T17:10:38","date_gmt":"2024-05-08T09:10:38","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/170566.html"},"modified":"2024-05-08T17:10:45","modified_gmt":"2024-05-08T09:10:45","slug":"javascript-%e7%bc%96%e7%a8%8b%e4%b8%ad%e5%a6%82%e4%bd%95%e5%b0%86-2-%e8%bf%9b%e5%88%b6%e8%bd%ac%e4%b8%ba-10-%e8%bf%9b%e5%88%b6","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/170566.html","title":{"rendered":"javascript \u7f16\u7a0b\u4e2d\u5982\u4f55\u5c06 2 \u8fdb\u5236\u8f6c\u4e3a 10 \u8fdb\u5236"},"content":{"rendered":"<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/27041415\/cf030aec-d4a7-42bf-a65f-12ea14102d74.webp\" alt=\"javascript \u7f16\u7a0b\u4e2d\u5982\u4f55\u5c06 2 \u8fdb\u5236\u8f6c\u4e3a 10 \u8fdb\u5236\" \/><\/p>\n<p><p>\u5728JavaScript\u7f16\u7a0b\u4e2d\uff0c\u5c062\u8fdb\u5236\u8f6c\u4e3a10\u8fdb\u5236\u7684\u65b9\u6cd5\u662f\u4f7f\u7528\u5185\u7f6e\u7684<code>parseInt<\/code>\u51fd\u6570\uff0c\u7ed3\u5408\u4e8c\u8fdb\u5236\u8868\u793a\u5b57\u7b26\u4e32\uff0c<strong>\u6307\u5b9a2\u4f5c\u4e3a\u8f6c\u6362\u57fa\u6570<\/strong>\u3002\u5177\u4f53\u6b65\u9aa4\u6d89\u53ca\u63a5\u53d7\u4e00\u4e2a\u4ee5&#039;0b&#039;\u5f00\u5934\u7684\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\uff0c\u4f20\u9012\u7ed9<code>parseInt<\/code>\u51fd\u6570\uff0c\u5e76\u6307\u5b9a\u7b2c\u4e8c\u4e2a\u53c2\u6570\u4e3a2\uff0c\u4ee5\u901a\u77e5\u51fd\u6570\u76f8\u5173\u7684\u6570\u5b57\u57fa\u5e95\u3002<\/p>\n<\/p>\n<p><p>\u4f8b\u5982\uff0c\u5982\u679c\u4f60\u6709\u4e00\u4e2a\u4e8c\u8fdb\u5236\u6570 &#039;1011&#039;\uff0c\u8f6c\u6362\u4e3a\u5341\u8fdb\u5236\u53ef\u4ee5\u8fd9\u6837\u505a\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-javascript\">let binaryString = &#039;1011&#039;;<\/p>\n<p>let decimalNumber = parseInt(binaryString, 2);<\/p>\n<p>console.log(decimalNumber); \/\/ \u8f93\u51fa11<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u91cc<code>parseInt<\/code>\u51fd\u6570\u89e3\u6790\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32 &#039;1011&#039;\uff0c\u5e76\u4ee510\u8fdb\u5236\u6570\u5f62\u5f0f\u8fd4\u56de\u7ed3\u679c11\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u7406\u89e3\u4e8c\u8fdb\u5236\u8f6c\u5341\u8fdb\u5236\u8fc7\u7a0b<\/h3>\n<\/p>\n<p><p>\u4e3a\u4e86\u6df1\u5165\u7406\u89e3\u8fd9\u4e2a\u8f6c\u6362\u8fc7\u7a0b\uff0c\u6211\u4eec\u9700\u8981\u77e5\u9053\u4e00\u4e2a\u4e8c\u8fdb\u5236\u6570\u6bcf\u4e00\u4f4d\u7684\u503c\u662f\u5982\u4f55\u8ba1\u7b97\u7684\u3002\u4e8c\u8fdb\u5236\u6570\u7cfb\u7edf\u53ea\u4f7f\u7528\u4e24\u4e2a\u6570\u5b57\uff1a0\u548c1\u3002\u6bcf\u4e00\u4f4d\u7684\u503c\u662f\u57fa\u4e8e2\u7684\u5e42\u6b21\u65b9\u3002\u4ece\u53f3\u5230\u5de6\u6570\uff08\u4e5f\u5c31\u662f\u4ece\u4f4e\u4f4d\u5230\u9ad8\u4f4d\uff09\uff0c\u7b2c\u4e00\u4f4d\u7684\u503c\u662f(2^0)\uff0c\u7b2c\u4e8c\u4f4d\u662f(2^1)\uff0c\u7b2c\u4e09\u4f4d\u662f(2^2)\uff0c\u4ee5\u6b64\u7c7b\u63a8\u3002<\/p>\n<\/p>\n<p><h4>\u4e3e\u4f8b\u8bf4\u660e<\/h4>\n<\/p>\n<p><p>\u4ee5\u4e8c\u8fdb\u5236\u6570 &#039;1011&#039; \u4e3a\u4f8b\uff0c\u6bcf\u4f4d\u7684\u5341\u8fdb\u5236\u503c\u5206\u522b\u662f\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u7b2c\u4e00\u4f4d\uff08\u4ece\u53f3\u6570\u7b2c\u4e00\u4f4d\uff091\u7684\u503c\u662f(1 \\times 2^0 = 1)<\/li>\n<li>\u7b2c\u4e8c\u4f4d0\u7684\u503c\u662f(0 \\times 2^1 = 0)<\/li>\n<li>\u7b2c\u4e09\u4f4d1\u7684\u503c\u662f(1 \\times 2^2 = 4)<\/li>\n<li>\u7b2c\u56db\u4f4d1\u7684\u503c\u662f(1 \\times 2^3 = 8)<\/li>\n<\/ul>\n<p><p>\u5c06\u4e0a\u8ff0\u6240\u6709\u503c\u76f8\u52a0\uff0c\u5373\u53ef\u5f97\u5230\u5176\u5341\u8fdb\u5236\u8868\u793a\uff1a(8 + 0 + 4 + 1 = 13)\u3002\u6240\u4ee5\uff0c\u4e8c\u8fdb\u5236\u7684&#039;1011&#039;\u7b49\u4e8e\u5341\u8fdb\u5236\u768413\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001\u4f7f\u7528<code>parseInt<\/code>\u51fd\u6570<\/h3>\n<\/p>\n<p><p><code>parseInt<\/code>\u65b9\u6cd5\u662fJavaScript\u4e2d\u9884\u5b9a\u4e49\u7684\u51fd\u6570\uff0c\u7528\u4e8e\u5c06\u5b57\u7b26\u4e32\u53c2\u6570\u89e3\u6790\u6210\u6307\u5b9a\u57fa\u6570\u7684\u6574\u6570\u3002\u5f53\u4f7f\u7528\u8be5\u65b9\u6cd5\u65f6\uff0c<strong>\u9700\u8981\u4e24\u4e2a\u53c2\u6570\uff1a\u5f85\u8f6c\u6362\u7684\u5b57\u7b26\u4e32\u548c\u8f6c\u6362\u6240\u7528\u7684\u57fa\u6570<\/strong>\u3002<\/p>\n<\/p>\n<p><h4>\u51fd\u6570\u4f7f\u7528\u65b9\u6cd5<\/h4>\n<\/p>\n<p><p>\u8be5\u51fd\u6570\u7684\u4f7f\u7528\u65b9\u5f0f\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-javascript\">parseInt(string, radix);<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5176\u4e2d<code>string<\/code>\u8868\u793a\u8981\u89e3\u6790\u7684\u5b57\u7b26\u4e32\uff0c\u800c<code>radix<\/code>\u662f\u4e00\u4e2a\u4ecb\u4e8e2\u523036\u4e4b\u95f4\u7684\u6574\u6570\uff0c\u4ee3\u8868\u5b57\u7b26\u4e32\u7684\u57fa\u6570\u3002<\/p>\n<\/p>\n<p><h4>\u8f6c\u6362\u5b9e\u4f8b<\/h4>\n<\/p>\n<p><pre><code class=\"language-javascript\">let binaryString = &#039;1101&#039;;<\/p>\n<p>let decimalNumber = parseInt(binaryString, 2);<\/p>\n<p>console.log(decimalNumber); \/\/ \u8f93\u51fa13<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4e3a\u4e86\u4fdd\u8bc1\u8f6c\u6362\u7684\u51c6\u786e\u6027\uff0c<strong>\u5fc5\u987b\u786e\u4fdd\u63d0\u4f9b\u7684\u5b57\u7b26\u4e32\u662f\u4e00\u4e2a\u6709\u6548\u7684\u4e8c\u8fdb\u5236\u6570\u5b57\u7b26\u4e32<\/strong>\uff0c\u5e76\u4e14\u8be5\u529f\u80fd\u662f\u53ef\u9760\u4e14\u7b80\u4fbf\u7684\u8f6c\u6362\u65b9\u6cd5\u3002<\/p>\n<\/p>\n<p><h3>\u4e09\u3001\u624b\u52a8\u5b9e\u73b0\u8f6c\u6362\u7b97\u6cd5<\/h3>\n<\/p>\n<p><p>\u867d\u7136\u5728\u65e5\u5e38\u7f16\u7a0b\u4e2d\u7528<code>parseInt<\/code>\u51fd\u6570\u5c31\u8db3\u591f\u4e86\uff0c\u4e86\u89e3\u5982\u4f55\u624b\u52a8\u5c06\u4e8c\u8fdb\u5236\u6570\u8f6c\u4e3a\u5341\u8fdb\u5236\u6570\u4e5f\u662f\u5341\u5206\u6709\u7528\u7684\uff0c\u5c24\u5176\u662f\u5728\u9762\u8bd5\u6216\u8005\u7406\u8bba\u5b66\u4e60\u4e2d\u3002<\/p>\n<\/p>\n<p><h4>\u57fa\u672c\u539f\u7406<\/h4>\n<\/p>\n<p><p>\u624b\u52a8\u8f6c\u6362\u7684\u539f\u7406\u540c\u8ba1\u7b97\u673a\u6267\u884c\u8be5\u4efb\u52a1\u7684\u539f\u7406\u5e76\u65e0\u4e8c\u81f4\u3002\u6211\u4eec\u9700\u8981\u8fed\u4ee3\u4e8c\u8fdb\u5236\u6570\u7684\u6bcf\u4e00\u4f4d\uff0c\u5e76\u4e14\u7d2f\u52a0\u6bcf\u4e00\u4f4d\u4ee3\u8868\u7684\u5341\u8fdb\u5236\u503c\u3002<\/p>\n<\/p>\n<p><h4>\u5b9e\u73b0\u6b65\u9aa4<\/h4>\n<\/p>\n<ol>\n<li>\u521d\u59cb\u5316\u4e00\u4e2a<code>sum<\/code>\u53d8\u91cf\u4e3a0\u3002<\/li>\n<li>\u4ece\u4e8c\u8fdb\u5236\u6570\u7684\u6700\u4f4e\u4f4d\uff08\u53f3\u4fa7\uff09\u5f00\u59cb\u904d\u5386\uff0c\u5bf9\u4e8e\u6bcf\u4e00\u4f4d\uff1a\n<ul>\n<li>\u5982\u679c\u5f53\u524d\u4f4d\u662f1\uff0c\u5219\u5c06<code>2<\/code>\u7684<code>\u5f53\u524d\u4f4d\u7d22\u5f15<\/code>\u6b21\u5e42\u52a0\u5230<code>sum<\/code>\u4e0a\u3002<\/li>\n<li>\u5982\u679c\u5f53\u524d\u4f4d\u662f0\uff0c\u5219\u8df3\u8fc7\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\u5b8c\u6210\u6240\u6709\u4f4d\u7684\u904d\u5386\u540e\uff0c<code>sum<\/code>\u5c31\u662f\u76f8\u5e94\u7684\u5341\u8fdb\u5236\u6570\u3002<\/li>\n<\/ol>\n<p><h4>\u4ee3\u7801\u793a\u4f8b<\/h4>\n<\/p>\n<p><pre><code class=\"language-javascript\">function binaryToDecimal(binaryString) {<\/p>\n<p>    let sum = 0;<\/p>\n<p>    for(let i = binaryString.length - 1; i &gt;= 0; i--) {<\/p>\n<p>        sum += binaryString[i] === &#039;1&#039; ? Math.pow(2, binaryString.length - 1 - i) : 0;<\/p>\n<p>    }<\/p>\n<p>    return sum;<\/p>\n<p>}<\/p>\n<p>console.log(binaryToDecimal(&#039;1011&#039;)); \/\/ \u8f93\u51fa11<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u56db\u3001\u8f6c\u6362\u7684\u5e94\u7528\u573a\u666f<\/h3>\n<\/p>\n<p><p>\u4e8c\u8fdb\u5236\u548c\u5341\u8fdb\u5236\u7684\u8f6c\u6362\u5728\u7f16\u7a0b\u4e2d\u6709\u8bf8\u591a\u5e94\u7528\u573a\u666f\u3002\u4f8b\u5982\uff0c<strong>\u5904\u7406\u4f4e\u7ea7\u7f16\u7a0b\u8bed\u8a00\u4e2d\u7684\u4e8c\u8fdb\u5236\u6570\u636e<\/strong>\u3001\u5bf9<strong>\u6587\u4ef6\u548c\u6570\u636e\u6d41\u7684\u4f4d\u64cd\u4f5c<\/strong>\u7b49\u7b49\uff0c\u90fd\u9700\u8981\u5bf9\u8fd9\u4e24\u79cd\u8fdb\u5236\u6570\u8fdb\u884c\u7075\u6d3b\u8f6c\u6362\u3002<\/p>\n<\/p>\n<p><h4>\u5e94\u7528\u5b9e\u4f8b<\/h4>\n<\/p>\n<p><p>\u5728\u67d0\u4e9b\u7f51\u7edc\u5e94\u7528\u7f16\u7a0b\u63a5\u53e3\uff08API\uff09\u4e2d\uff0c\u53ef\u80fd\u9700\u8981\u7528\u5230\u4f4d\u63a9\u7801\u6765\u8bbe\u7f6e\u6743\u9650\u3002\u8fd9\u662f\u4e00\u79cd\u4f7f\u7528\u4f4d\u4e0a\u7684 0 \u548c 1 \u6765\u8868\u793a\u5f00\u5173\u72b6\u6001\u7684\u65b9\u6cd5\uff0c\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u4e8c\u8fdb\u5236\u8f6c\u5341\u8fdb\u5236\u7684\u77e5\u8bc6\u5c31\u975e\u5e38\u91cd\u8981\u4e86\u3002<\/p>\n<\/p>\n<p><h3>\u4e94\u3001\u6ce8\u610f\u548c\u6311\u6218<\/h3>\n<\/p>\n<ul>\n<li><strong>\u6709\u6548\u6027\u68c0\u67e5<\/strong>\uff1a\u5728\u8f6c\u6362\u4e4b\u524d\u5e94\u68c0\u67e5\u63d0\u4f9b\u7684\u5b57\u7b26\u4e32\u662f\u5426\u771f\u7684\u662f\u4e8c\u8fdb\u5236\u6570\u3002<\/li>\n<li><strong>\u5f02\u5e38\u548c\u9519\u8bef\u5904\u7406<\/strong>\uff1a\u7f16\u5199\u4ee3\u7801\u65f6\u8003\u8651\u8fb9\u7f18\u60c5\u51b5\u548c\u6f5c\u5728\u7684\u8f6c\u6362\u9519\u8bef\u3002<\/li>\n<li><strong>\u6027\u80fd\u4f18\u5316<\/strong>\uff1a\u5728\u7528 JavaScript \u624b\u52a8\u5b9e\u73b0\u7b97\u6cd5\u65f6\uff0c\u8003\u8651\u5982\u4f55\u51cf\u5c11\u8ba1\u7b97\u91cf\u548c\u63d0\u9ad8\u6267\u884c\u6548\u7387\u3002<\/li>\n<\/ul>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u4ecb\u7ecd\uff0c\u6211\u4eec\u8be6\u7ec6\u4e86\u89e3\u4e86JavaScript\u4e2d\u5c062\u8fdb\u5236\u8f6c\u4e3a10\u8fdb\u5236\u7684\u57fa\u672c\u65b9\u6cd5\u3001\u539f\u7406\u53ca\u5b9e\u8df5\u6280\u5de7\uff0c\u8fd9\u4e9b\u90fd\u662f\u7f16\u7a0b\u4e2d\u5e38\u89c1\u7684\u9700\u6c42\uff0c\u638c\u63e1\u5b83\u4eec\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u5904\u7406\u5404\u79cd\u76f8\u5173\u7684\u7f16\u7a0b\u4efb\u52a1\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p><strong>\u5982\u4f55\u7528 JavaScript \u5c06\u4e8c\u8fdb\u5236\u6570\u8f6c\u4e3a\u5341\u8fdb\u5236\u6570\uff1f<\/strong><\/p>\n<ul>\n<li><strong>\u4ec0\u4e48\u662f\u4e8c\u8fdb\u5236\u6570\u548c\u5341\u8fdb\u5236\u6570\uff1f<\/strong><br \/>\n\u4e8c\u8fdb\u5236\u6570\u662f\u4e00\u79cd\u75310\u548c1\u7ec4\u6210\u7684\u6570\u5236\u7cfb\u7edf\uff0c\u800c\u5341\u8fdb\u5236\u6570\u662f\u6211\u4eec\u901a\u5e38\u4f7f\u7528\u7684\u6570\u5236\u7cfb\u7edf\uff0c\u5305\u542b0-9\u8fd910\u4e2a\u6570\u5b57\u3002<\/li>\n<li><strong>\u5982\u4f55\u5c06\u4e8c\u8fdb\u5236\u6570\u8f6c\u4e3a\u5341\u8fdb\u5236\u6570\uff1f<\/strong><br \/>\n\u8981\u5c06\u4e8c\u8fdb\u5236\u6570\u8f6c\u4e3a\u5341\u8fdb\u5236\u6570\uff0c\u53ef\u4ee5\u4f7f\u7528 JavaScript \u4e2d\u7684 parseInt() \u51fd\u6570\u3002\u8be5\u51fd\u6570\u63a5\u53d7\u4e24\u4e2a\u53c2\u6570\uff0c\u8981\u8f6c\u6362\u7684\u4e8c\u8fdb\u5236\u6570\u548c\u57fa\u6570\uff08\u8fd9\u91cc\u662f2\uff0c\u4ee3\u8868\u4e8c\u8fdb\u5236\uff09\u3002\u4f8b\u5982\uff1aparseInt(&quot;110&quot;, 2) \u5c06\u8fd4\u56de\u5341\u8fdb\u5236\u65706\u3002<\/li>\n<li><strong>\u6709\u6ca1\u6709\u5176\u4ed6\u65b9\u5f0f\u5c06\u4e8c\u8fdb\u5236\u6570\u8f6c\u4e3a\u5341\u8fdb\u5236\u6570\uff1f<\/strong><br \/>\n\u9664\u4e86\u4f7f\u7528 parseInt() \u51fd\u6570\uff0c\u8fd8\u53ef\u4ee5\u4f7f\u7528 JavaScript \u4e2d\u7684 Number() \u6784\u9020\u51fd\u6570\u5c06\u4e8c\u8fdb\u5236\u6570\u8f6c\u4e3a\u5341\u8fdb\u5236\u6570\u3002\u4f8b\u5982\uff1aNumber(&quot;110&quot;) \u5c06\u8fd4\u56de\u5341\u8fdb\u5236\u65706\u3002<\/li>\n<\/ul>\n<p><strong>\u5728 JavaScript \u7f16\u7a0b\u4e2d\uff0c\u5982\u4f55\u5c06\u4e8c\u8fdb\u5236\u6570\u8f6c\u4e3a\u5341\u8fdb\u5236\u6570\uff1f<\/strong><\/p>\n<ul>\n<li><strong>\u4e8c\u8fdb\u5236\u6570\u548c\u5341\u8fdb\u5236\u6570\u7684\u5b9a\u4e49\u662f\u4ec0\u4e48\uff1f<\/strong><br \/>\n\u4e8c\u8fdb\u5236\u6570\u662f\u75310\u548c1\u7ec4\u6210\u7684\u6570\u5236\u7cfb\u7edf\uff0c\u800c\u5341\u8fdb\u5236\u6570\u662f\u6211\u4eec\u901a\u5e38\u4f7f\u7528\u7684\u6570\u5236\u7cfb\u7edf\uff0c\u5305\u542b0-9\u8fd910\u4e2a\u6570\u5b57\u3002<\/li>\n<li><strong>\u5982\u4f55\u4f7f\u7528 JavaScript \u5c06\u4e8c\u8fdb\u5236\u6570\u8f6c\u4e3a\u5341\u8fdb\u5236\u6570\uff1f<\/strong><br \/>\n\u4f7f\u7528 JavaScript \u7684 parseInt() \u51fd\u6570\u53ef\u4ee5\u5c06\u4e8c\u8fdb\u5236\u6570\u8f6c\u4e3a\u5341\u8fdb\u5236\u6570\u3002\u8be5\u51fd\u6570\u63a5\u53d7\u4e24\u4e2a\u53c2\u6570\uff0c\u8981\u8f6c\u6362\u7684\u4e8c\u8fdb\u5236\u6570\u548c\u57fa\u6570\uff08\u8fd9\u91cc\u662f2\uff0c\u4ee3\u8868\u4e8c\u8fdb\u5236\uff09\u3002\u4f8b\u5982\uff1aparseInt(&quot;110&quot;, 2) \u5c06\u8fd4\u56de\u5341\u8fdb\u5236\u65706\u3002<\/li>\n<li><strong>\u8fd8\u6709\u5176\u4ed6\u5c06\u4e8c\u8fdb\u5236\u6570\u8f6c\u4e3a\u5341\u8fdb\u5236\u6570\u7684\u65b9\u6cd5\u5417\uff1f<\/strong><br \/>\n\u9664\u4e86\u4f7f\u7528 parseInt() \u51fd\u6570\uff0c\u8fd8\u53ef\u4ee5\u4f7f\u7528 JavaScript \u4e2d\u7684 Number() \u6784\u9020\u51fd\u6570\u5c06\u4e8c\u8fdb\u5236\u6570\u8f6c\u4e3a\u5341\u8fdb\u5236\u6570\u3002\u4f8b\u5982\uff1aNumber(&quot;110&quot;) \u5c06\u8fd4\u56de\u5341\u8fdb\u5236\u65706\u3002<\/li>\n<\/ul>\n<p><strong>\u5982\u4f55\u4f7f\u7528 JavaScript \u8fdb\u884c\u4e8c\u8fdb\u5236\u5230\u5341\u8fdb\u5236\u7684\u8f6c\u6362\uff1f<\/strong><\/p>\n<ul>\n<li><strong>\u4e8c\u8fdb\u5236\u6570\u548c\u5341\u8fdb\u5236\u6570\u7684\u5b9a\u4e49\u662f\u4ec0\u4e48\uff1f<\/strong><br \/>\n\u4e8c\u8fdb\u5236\u6570\u662f\u75310\u548c1\u7ec4\u6210\u7684\u4e00\u79cd\u6570\u5236\u7cfb\u7edf\uff0c\u800c\u5341\u8fdb\u5236\u6570\u662f\u6211\u4eec\u901a\u5e38\u4f7f\u7528\u7684\u6570\u5236\u7cfb\u7edf\uff0c\u5305\u542b0-9\u8fd910\u4e2a\u6570\u5b57\u3002<\/li>\n<li><strong>\u600e\u6837\u4f7f\u7528 JavaScript \u6765\u5c06\u4e8c\u8fdb\u5236\u6570\u8f6c\u4e3a\u5341\u8fdb\u5236\u6570\uff1f<\/strong><br \/>\n\u5728 JavaScript \u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528 parseInt() \u51fd\u6570\u6765\u5c06\u4e8c\u8fdb\u5236\u6570\u8f6c\u4e3a\u5341\u8fdb\u5236\u6570\u3002\u8be5\u51fd\u6570\u63a5\u53d7\u4e24\u4e2a\u53c2\u6570\uff0c\u4e00\u4e2a\u662f\u8981\u8f6c\u6362\u7684\u4e8c\u8fdb\u5236\u6570\uff0c\u53e6\u4e00\u4e2a\u662f\u57fa\u6570\uff08\u8fd9\u91cc\u662f2\uff0c\u4ee3\u8868\u4e8c\u8fdb\u5236\uff09\u3002\u4f8b\u5982\uff1aparseInt(&quot;110&quot;, 2) \u5c06\u8fd4\u56de\u5341\u8fdb\u5236\u65706\u3002<\/li>\n<li><strong>\u9664\u4e86\u4f7f\u7528 parseInt() \u51fd\u6570\uff0c\u8fd8\u6709\u5176\u4ed6\u65b9\u6cd5\u5c06\u4e8c\u8fdb\u5236\u6570\u8f6c\u4e3a\u5341\u8fdb\u5236\u6570\u5417\uff1f<\/strong><br \/>\n\u9664\u4e86\u4f7f\u7528 parseInt() \u51fd\u6570\uff0c\u6211\u4eec\u8fd8\u53ef\u4ee5\u4f7f\u7528 JavaScript \u4e2d\u7684 Number() \u6784\u9020\u51fd\u6570\u5c06\u4e8c\u8fdb\u5236\u6570\u8f6c\u4e3a\u5341\u8fdb\u5236\u6570\u3002\u4f8b\u5982\uff1aNumber(&quot;110&quot;) \u5c06\u8fd4\u56de\u5341\u8fdb\u5236\u65706\u3002\u8fd9\u662f\u53e6\u4e00\u79cd\u5b9e\u73b0\u4e8c\u8fdb\u5236\u5230\u5341\u8fdb\u5236\u8f6c\u6362\u7684\u65b9\u5f0f\u3002<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"\u5728JavaScript\u7f16\u7a0b\u4e2d\uff0c\u5c062\u8fdb\u5236\u8f6c\u4e3a10\u8fdb\u5236\u7684\u65b9\u6cd5\u662f\u4f7f\u7528\u5185\u7f6e\u7684parseInt\u51fd\u6570\uff0c\u7ed3\u5408\u4e8c\u8fdb\u5236\u8868\u793a\u5b57\u7b26\u4e32 [&hellip;]","protected":false},"author":3,"featured_media":170578,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/170566"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=170566"}],"version-history":[{"count":0,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/170566\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/170578"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=170566"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=170566"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=170566"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}