{"id":165984,"date":"2024-05-08T15:27:36","date_gmt":"2024-05-08T07:27:36","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/165984.html"},"modified":"2024-05-08T15:27:45","modified_gmt":"2024-05-08T07:27:45","slug":"javascript%e4%b8%ad%e7%9a%84%e6%97%a0%e7%a9%b7%e5%a4%a7%e6%98%af%e4%bb%80%e4%b9%88","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/165984.html","title":{"rendered":"JavaScript\u4e2d\u7684\u65e0\u7a77\u5927\u662f\u4ec0\u4e48"},"content":{"rendered":"<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/26233008\/b6c068e1-4925-44b9-9765-12e14c1682c1.webp\" alt=\"JavaScript\u4e2d\u7684\u65e0\u7a77\u5927\u662f\u4ec0\u4e48\" \/><\/p>\n<p><p><strong>JavaScript\u4e2d\u7684\u65e0\u7a77\u5927\u8868\u73b0\u4e3a<code>Infinity<\/code>\uff0c\u5b83\u662fJavaScript\u73af\u5883\u4e2d\u4e00\u4e2a\u7279\u6b8a\u7684\u6570\u503c\uff0c\u7528\u6765\u8868\u793a\u6570\u5b66\u4e0a\u7684\u65e0\u9650\u5927\u3002<\/strong> \u5176\u4e2d\uff0c\u5305\u62ec\u4e86<strong>\u88ab\u96f6\u9664\u7684\u6b63\u6570\u7ed3\u679c\u3001\u8d85\u51faJavaScript\u80fd\u8868\u793a\u7684\u6700\u5927\u6570\u503c\u8fb9\u754c\u7684\u60c5\u51b5<\/strong>\u3002<code>Infinity<\/code>\u5728JavaScript\u4e2d\u662f\u4e00\u4e2a\u5168\u5c40\u5c5e\u6027\uff0c\u4e5f\u5c31\u662f\u8bf4\u5b83\u662f\u5168\u5c40\u4f5c\u7528\u57df\u4e0b\u7684\u4e00\u4e2a\u53d8\u91cf\uff0c\u56e0\u6b64\u53ef\u4ee5\u5728\u4ee3\u7801\u7684\u4efb\u4f55\u4f4d\u7f6e\u88ab\u8bbf\u95ee\u3002<\/p>\n<\/p>\n<p><p>\u7279\u522b\u5730\uff0c\u5f53\u6211\u4eec\u8c08\u5230<strong>\u8d85\u51faJavaScript\u80fd\u8868\u793a\u7684\u6700\u5927\u6570\u503c\u8fb9\u754c\u7684\u60c5\u51b5<\/strong>\u65f6\uff0c\u610f\u5473\u7740JavaScript\u4e2d\u80fd\u8868\u793a\u7684\u6570\u503c\u662f\u6709\u4e0a\u9650\u7684\u3002\u6839\u636eIEEE 754\u6807\u51c6\uff0cJavaScript\u4f7f\u7528\u53cc\u7cbe\u5ea664\u4f4d\u683c\u5f0f\u6765\u8868\u793a\u6570\u5b57\uff0c\u8fd9\u51b3\u5b9a\u4e86\u5176\u80fd\u8868\u793a\u7684\u6700\u5927\u6b63\u6570\u662f<code>Number.MAX_VALUE<\/code>\uff08\u7ea6\u7b49\u4e8e1.79E+308\uff09\u3002\u4e00\u65e6\u8ba1\u7b97\u7ed3\u679c\u8d85\u8fc7\u8fd9\u4e2a\u503c\uff0c\u4fbf\u4f1a\u8fd4\u56de<code>Infinity<\/code>\uff0c\u8fd9\u79cd\u673a\u5236\u4fdd\u8bc1\u4e86JavaScript\u80fd\u5728\u5904\u7406\u6781\u5927\u6570\u503c\u65f6\u4e0d\u4f1a\u629b\u51fa\u9519\u8bef\uff0c\u800c\u662f\u63d0\u4f9b\u4e86\u4e00\u4e2a\u53ef\u64cd\u4f5c\u7684\u65e0\u7a77\u5927\u7684\u6982\u5ff5\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001JAVASCRIPT\u4e2d\u7684\u65e0\u7a77\u5927<code>INFINITY<\/code><\/h3>\n<\/p>\n<p><p>\u5728JavaScript\u4e2d\uff0c<code>Infinity<\/code>\u662f\u4e00\u4e2a\u7279\u6b8a\u7684\u503c\uff0c\u5177\u6709\u4e00\u4e9b\u6709\u8da3\u7684\u5c5e\u6027\u548c\u884c\u4e3a\u3002\u9996\u5148\uff0c<code>Infinity<\/code>\u5927\u4e8e\u4efb\u4f55\u5176\u4ed6\u6570\u503c\uff0c\u5305\u62ec\u5b83\u81ea\u5df1\u3002\u8fd9\u610f\u5473\u7740\uff0c\u6bd4\u8f83<code>Infinity<\/code>\u4e0e\u4efb\u4f55\u5176\u4ed6\u975e<code>Infinity<\/code>\u503c\u65f6\uff0c<code>Infinity<\/code>\u603b\u662f\u88ab\u8ba4\u4e3a\u662f\u66f4\u5927\u7684\u3002\u6b64\u5916\uff0c<code>-Infinity<\/code>\u5219\u662f\u8868\u793a\u8d1f\u65e0\u9650\u5927\uff0c\u5b83\u662f\u6240\u6709\u6570\u503c\u4e2d\u6700\u5c0f\u7684\u3002<\/p>\n<\/p>\n<p><p><code>Infinity<\/code>\u7528\u4e8e\u5904\u7406\u6570\u5b66\u8ba1\u7b97\u4e2d\u53ef\u80fd\u9047\u5230\u7684\u65e0\u9650\u5927\u7684\u573a\u666f\u3002\u4f8b\u5982\uff0c\u5f53\u4f60\u5c1d\u8bd5\u7528\u6b63\u6570\u9664\u4ee50\u65f6\uff0c\u7ed3\u679c\u4f1a\u8fd4\u56de<code>Infinity<\/code>\uff0c\u800c\u8d1f\u6570\u9664\u4ee50\u5219\u4f1a\u8fd4\u56de<code>-Infinity<\/code>\u3002\u8fd9\u79cd\u5904\u7406\u65b9\u5f0f\uff0c\u867d\u7136\u4e0e\u6570\u5b66\u4e0a\u7684\u5b9a\u4e49\u6709\u6240\u533a\u522b\uff0c\u4f46\u4e3a\u7f16\u7a0b\u63d0\u4f9b\u4e86\u4fbf\u5229\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001\u5229\u7528<code>INFINITY<\/code>\u5728\u7f16\u7a0b\u4e2d\u7684\u5e94\u7528<\/h3>\n<\/p>\n<p><p>\u5728\u5b9e\u9645\u7f16\u7a0b\u4e2d\uff0c<code>Infinity<\/code>\u53ef\u4ee5\u7528\u4e8e\u591a\u79cd\u573a\u5408\u3002\u6bd4\u5982\uff0c\u5728\u5bfb\u627e\u4e00\u7ec4\u6570\u503c\u4e2d\u7684\u6700\u5927\u503c\u6216\u6700\u5c0f\u503c\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528<code>-Infinity<\/code>\u548c<code>Infinity<\/code>\u4f5c\u4e3a\u521d\u59cb\u6bd4\u8f83\u7684\u503c\u3002<\/p>\n<\/p>\n<p><p>\u6b64\u5916\uff0c<code>Infinity<\/code>\u5728\u5904\u7406\u53ef\u80fd\u51fa\u73b0\u65e0\u9650\u5faa\u73af\u7684\u9012\u5f52\u51fd\u6570\u65f6\uff0c\u53ef\u4ee5\u4f5c\u4e3a\u4e00\u4e2a\u7ec8\u6b62\u6761\u4ef6\u3002\u4f8b\u5982\uff0c\u5f53\u8ba1\u7b97\u67d0\u4e2a\u6570\u5b66\u51fd\u6570\u7684\u8fd1\u4f3c\u503c\uff0c\u4f46\u53c8\u4e0d\u5e0c\u671b\u5728\u8fbe\u5230\u67d0\u4e2a\u6781\u5927\u7684\u8fed\u4ee3\u6b21\u6570\u540e\u4ecd\u7136\u8fd0\u884c\uff0c\u5c31\u53ef\u4ee5\u8bbe\u7f6e<code>Infinity<\/code>\u4f5c\u4e3a\u9608\u503c\uff0c\u4e00\u65e6\u8d85\u8fc7\u8fd9\u4e2a\u9608\u503c\u5219\u7ec8\u6b62\u8ba1\u7b97\u3002<\/p>\n<\/p>\n<p><h3>\u4e09\u3001\u7406\u89e3JS\u4e2d\u7684<code>NUMBER.MAX_VALUE<\/code><\/h3>\n<\/p>\n<p><p><code>Number.MAX_VALUE<\/code>\u662fJavaScript\u4e2d\u80fd\u8868\u793a\u7684\u6700\u5927\u6b63\u6570\u503c\uff0c\u5176\u503c\u5927\u7ea6\u4e3a1.79E+308\u3002\u4efb\u4f55\u8d85\u8fc7\u8fd9\u4e2a\u503c\u7684\u8ba1\u7b97\u7ed3\u679c\u90fd\u4f1a\u8fd4\u56de<code>Infinity<\/code>\u3002\u4e86\u89e3<code>Number.MAX_VALUE<\/code>\u5bf9\u4e8e\u907f\u514d\u8fd0\u7b97\u65f6\u7684\u6ea2\u51fa\u548c\u4e0d\u7cbe\u786e\u8ba1\u7b97\u81f3\u5173\u91cd\u8981\u3002<\/p>\n<\/p>\n<p><p>\u4f8b\u5982\uff0c\u5728\u8fdb\u884c\u91d1\u878d\u8ba1\u7b97\u6216\u79d1\u5b66\u8ba1\u7b97\u65f6\uff0c\u7cbe\u5ea6\u975e\u5e38\u91cd\u8981\u3002\u5982\u679c\u4e0d\u52a0\u4ee5\u9650\u5236\u548c\u5224\u65ad\uff0c\u5f88\u5bb9\u6613\u56e0\u4e3a\u8d85\u51fa<code>Number.MAX_VALUE<\/code>\u800c\u5f97\u5230\u4e0d\u7cbe\u786e\u6216\u610f\u6599\u4e4b\u5916\u7684\u7ed3\u679c\u3002\u56e0\u6b64\uff0c\u5728\u8fdb\u884c\u53ef\u80fd\u4ea7\u751f\u5927\u6570\u8fd0\u7b97\u7684\u7f16\u7a0b\u65f6\uff0c\u9700\u8981\u8003\u8651\u5230<code>Number.MAX_VALUE<\/code>\u7684\u9650\u5236\u3002<\/p>\n<\/p>\n<p><h3>\u56db\u3001JAVASCRIPT\u4e2d\u7684<code>INFINITY<\/code>\u4e0e\u6570\u5b66\u65e0\u9650\u5927\u7684\u5173\u7cfb<\/h3>\n<\/p>\n<p><p>\u5c3d\u7ba1JavaScript\u4e2d\u7684<code>Infinity<\/code>\u4ee3\u8868\u4e86\u6570\u5b66\u4e0a\u7684\u65e0\u9650\u5927\u6982\u5ff5\uff0c\u4f46\u5b83\u4eec\u5728\u67d0\u4e9b\u65b9\u9762\u8fd8\u662f\u6709\u6240\u533a\u522b\u3002\u5728\u6570\u5b66\u4e2d\uff0c\u65e0\u9650\u5927\u662f\u4e00\u79cd\u6982\u5ff5\uff0c\u800c\u4e0d\u662f\u4e00\u4e2a\u5177\u4f53\u7684\u503c\u3002\u800c\u5728JavaScript\u4e2d\uff0c<code>Infinity<\/code>\u662f\u4e00\u4e2a\u53ef\u4ee5\u88ab\u91cf\u5316\u3001\u64cd\u4f5c\u548c\u6bd4\u8f83\u7684\u5b9e\u9645\u6570\u503c\u3002<\/p>\n<\/p>\n<p><p>\u8fd9\u79cd\u8bbe\u8ba1\u5141\u8bb8\u5f00\u53d1\u8005\u5728\u7f16\u7a0b\u4e2d\u5904\u7406\u65e0\u9650\u5927\u7684\u60c5\u51b5\uff0c\u800c\u65e0\u9700\u62c5\u5fc3\u65e0\u6cd5\u8868\u793a\u6216\u8ba1\u7b97\u65e0\u9650\u5927\u76f8\u5173\u7684\u95ee\u9898\u3002\u4f46\u662f\uff0c\u8fd9\u4e5f\u610f\u5473\u7740\u5728\u4f7f\u7528<code>Infinity<\/code>\u65f6\u9700\u8981\u8c28\u614e\uff0c\u907f\u514d\u5f15\u53d1\u903b\u8f91\u4e0a\u7684\u6df7\u6dc6\u6216\u8bef\u7528\u3002<\/p>\n<\/p>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u8ba8\u8bba\uff0c\u6211\u4eec\u4e0d\u5149\u770b\u5230\u4e86<strong>JavaScript\u4e2d\u65e0\u7a77\u5927<\/strong><code>Infinity<\/code>\u7684\u5b9a\u4e49\u548c\u7279\u6027\uff0c\u8fd8\u63a2\u7d22\u4e86\u5b83\u5728\u5b9e\u9645\u7f16\u7a0b\u4e2d\u7684\u5e94\u7528\u4ee5\u53ca\u5b83\u5982\u4f55\u4e0e\u6570\u5b66\u4e2d\u7684\u65e0\u9650\u5927\u6982\u5ff5\u76f8\u8054\u7cfb\u548c\u533a\u522b\u3002\u7406\u89e3\u8fd9\u4e9b\u5185\u5bb9\u5bf9\u4e8e\u6df1\u5165\u5229\u7528JavaScript\u5904\u7406\u590d\u6742\u8ba1\u7b97\u548c\u903b\u8f91\u5224\u65ad\u975e\u5e38\u6709\u5e2e\u52a9\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p><strong>\u4ec0\u4e48\u662fJavaScript\u4e2d\u7684\u65e0\u7a77\u5927\uff0c\u5982\u4f55\u8868\u793a\uff1f<\/strong><\/p>\n<p>JavaScript\u4e2d\u7684\u65e0\u7a77\u5927\u4ee3\u8868\u4e00\u4e2a\u8d85\u51fa\u53ef\u8ba1\u7b97\u8303\u56f4\u7684\u6570\u503c\u3002\u5b83\u53ef\u4ee5\u7528Infinity\u6765\u8868\u793a\u3002Infinity\u662fJavaScript\u4e2d\u7684\u4e00\u4e2a\u7279\u6b8a\u5e38\u91cf\uff0c\u5b83\u4ee3\u8868\u7740\u6b63\u65e0\u7a77\u5927\u3002\u4f7f\u7528\u8d1f\u53f7\u52a0Infinity\u53ef\u4ee5\u8868\u793a\u8d1f\u65e0\u7a77\u5927\u3002<\/p>\n<p><strong>\u5728JavaScript\u4e2d\u5982\u4f55\u5224\u65ad\u4e00\u4e2a\u6570\u662f\u5426\u4e3a\u65e0\u7a77\u5927\uff1f<\/strong><\/p>\n<p>\u5728JavaScript\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528isFinite()\u51fd\u6570\u6765\u5224\u65ad\u4e00\u4e2a\u6570\u662f\u5426\u4e3a\u6709\u9650\u6570\u3002\u5982\u679c\u4e00\u4e2a\u6570\u4e3a\u6709\u9650\u6570\uff0c\u5219\u8fd4\u56detrue\uff1b\u5982\u679c\u4e00\u4e2a\u6570\u4e3a\u65e0\u7a77\u5927\u3001NaN\uff08\u975e\u6570\u503c\uff09\u6216\u5b57\u7b26\u4e32\uff0c\u5219\u8fd4\u56defalse\u3002<\/p>\n<p><strong>\u5728JavaScript\u4e2d\u5982\u4f55\u8fdb\u884c\u65e0\u7a77\u5927\u7684\u6570\u503c\u8fd0\u7b97\uff1f<\/strong><\/p>\n<p>\u5728\u8fdb\u884c\u65e0\u7a77\u5927\u7684\u6570\u503c\u8fd0\u7b97\u65f6\uff0c\u9700\u8981\u6ce8\u610f\u4e00\u4e9b\u89c4\u5219\u3002\u4f8b\u5982\uff0c\u65e0\u7a77\u5927\u4e0e\u4efb\u4f55\u6570\u76f8\u52a0\u6216\u76f8\u51cf\u90fd\u5f97\u5230\u65e0\u7a77\u5927\uff1b\u65e0\u7a77\u5927\u4e58\u4ee5\u4efb\u4f55\u975e\u96f6\u6570\u90fd\u5f97\u5230\u65e0\u7a77\u5927\uff1b\u65e0\u7a77\u5927\u9664\u4ee5\u65e0\u7a77\u5927\u6216\u4efb\u4f55\u6570\u90fd\u5f97\u5230NaN\u7b49\u7b49\u3002\u5728\u8fdb\u884c\u65e0\u7a77\u5927\u7684\u6570\u503c\u8fd0\u7b97\u65f6\uff0c\u9700\u8981\u4ed4\u7ec6\u8003\u8651\u6570\u5b66\u903b\u8f91\u548c\u7a0b\u5e8f\u9700\u6c42\uff0c\u4ee5\u907f\u514d\u51fa\u73b0\u610f\u5916\u7684\u7ed3\u679c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"JavaScript\u4e2d\u7684\u65e0\u7a77\u5927\u8868\u73b0\u4e3aInfinity\uff0c\u5b83\u662fJavaScript\u73af\u5883\u4e2d\u4e00\u4e2a\u7279\u6b8a\u7684\u6570\u503c\uff0c\u7528\u6765\u8868\u793a\u6570 [&hellip;]","protected":false},"author":3,"featured_media":166005,"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\/165984"}],"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=165984"}],"version-history":[{"count":0,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/165984\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/166005"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=165984"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=165984"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=165984"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}