{"id":892,"date":"2022-03-10T21:05:26","date_gmt":"2022-03-10T13:05:26","guid":{"rendered":"http:\/\/www.henrycome.com\/wordpress\/?p=892"},"modified":"2022-03-10T21:05:26","modified_gmt":"2022-03-10T13:05:26","slug":"20220310210513","status":"publish","type":"post","link":"http:\/\/www.henrycome.com\/wordpress\/202203102105\/892","title":{"rendered":"P8-9-\u57fa\u7840-\u57fa\u672c\u6570\u636e\u7c7b\u578b\u548c\u8f6c\u6362.js"},"content":{"rendered":"<pre><code class=\"language-javascript\">\/\/\u57fa\u672c\u6570\u636e\u7c7b\u578b\n\n\/\/boolean,\u5e03\u5c14\u503c\n\nvar visible = true;\/\/\u65e0\u9700\u5f15\u53f7\nvar isEqual = false;\/\/\u65e0\u9700\u5f15\u53f7\n\n\/\/console\u663e\u793a\u7684\u7ed3\u679c\u4e5f\u65e0\u5f15\u53f7\nconsole.log(visible);\/\/true\n\n\/\/number\uff0c\u6570\u5b57\nvar num = 100;\/\/\u65e0\u9700\u5f15\u53f7\nvar floatingNum = 12.34;\/\/\u65e0\u9700\u5f15\u53f7\nvar negative = -100;\/\/\u65e0\u9700\u5f15\u53f7\n\n\/\/console\u663e\u793a\u7684\u7ed3\u679c\u4e5f\u65e0\u5f15\u53f7\nconsole.log(num);\/\/100\nconsole.log(floatingNum);\/\/12.34\nconsole.log(negative);\/\/-100\n\n\/\/string\uff0c\u5b57\u7b26\u4e32\n\/\/\u5355\u5f15\u53f7\u6216\u53cc\u5f15\u53f7\nvar str = &#039;hello!&#039;;\nconsole.log(str);\n\n\/\/undefined,\u672a\u5b9a\u4e49\uff08\u672a\u521d\u59cb\u5316\uff09\n\nvar notInitialized;\nconsole.log(notInitialized);\/\/undefined\nvar notInitialized2= undefined;\nconsole.log(notInitialized2);\/\/undefined\n\n\/\/null\uff0c\u662f\u503c\u7684\u4e00\u79cd\n\/\/null\u5df2\u7ecf\u8d4b\u503c\uff0c\u503c\u5c31\u662fnull\uff0c\u4ee3\u8868\u4e3a\u7a7a\uff0cundefined\u662f\u6ca1\u6709\u8d4b\u503c\uff08\u521d\u59cb\u5316\uff09\n\nvar emptyValue = null;\nconsole.log(emptyValue);\/\/\u5355\u72ec\u4e0d\u663e\u793a\nconsole.log(&#039;\u4e0a\u9762\u662fnull\u7684\u503c&#039;);\nconsole.log(emptyValue+&#039;\u5de6\u8fb9\u662fnull\u7684\u503c&#039;);\/\/\u4e00\u8d77\u62fc\u63a5\u663e\u793anull\n\n\/*\n\u603b\u7ed3\uff1a\u4ee5\u4e0a\u7b49\u4e8e\u53f7\u540e\u9762\u7684\u90fd\u662fliterals\uff0c\u5b57\u9762\u503c\uff0c\u4e0d\u53d8\u3002\u628a\u5b83\u8d4b\u503c\u7ed9\u53d8\u91cf\uff0c\u5c31\u6210\u4e86\u53d8\u91cf\u7684\u503c\u3002\n\u540e\u9762\u8bb2if\u7b49\u53ef\u4ee5\u62ff\u53d8\u91cf\u548c\u5b57\u9762\u503c\u8fdb\u884c\u6bd4\u8f83\u3002\n\u53e6\u5916\uff0c\u8fd8\u6709array\uff0cobject\uff0cfunction\u7b49\u7279\u6b8a\u6570\u636e\u7c7b\u578b\n\n*\/\n\n\/*P9-\u57fa\u7840-\u57fa\u672c\u6570\u636e\u7c7b\u578b\u8f6c\u6362 *\/\n\/\/JS\u662f\u52a8\u6001\u6570\u636e\u7c7b\u578b\uff0cvar\u5373\u53ef\uff0c\u4e0d\u5fc5\u6307\u5b9a\u7c7b\u578b\n\n\/\/typeof()\u53ef\u4ee5\u67e5\u770b\u53d8\u91cf\u7684\u6570\u636e\u7c7b\u578b\n\nconsole.log(typeof visible);\nconsole.log(typeof num);\nconsole.log(typeof floatingNum);\nconsole.log(typeof str);\nconsole.log(typeof notInitialized);\nconsole.log(typeof emptyValue);\/\/object,\u65e9\u671fECMA\u89c4\u8303\u662f\u8fd9\u4e48\u6765\u7684\uff0c\u4f46\u662fnull\u5b9e\u9645\u5c31\u662f\u57fa\u672c\u7c7b\u578b\n\nvar age=15;\nconsole.log(typeof age);\/\/number\nage=&#039;15&#039;\nconsole.log(typeof age);\/\/\u52a8\u6001\u53d8\u6210string\uff0c\u5e76\u4fdd\u6301\uff0c\u76f4\u5230\u4e00\u4e9b\u8d4b\u503c\u64cd\u4f5c\u8ba9\u5b83\u6539\u53d8\n\n\/\/\u6539\u53d8\u65b9\u6cd5\uff1a1.\u8d4b\u503c\u5176\u4ed6\u7684\u6570\u636e\u7c7b\u578b\uff0c2.\u4e0d\u540c\u6570\u636e\u7c7b\u578b\u53d8\u91cf\u4e4b\u95f4\u7684\u4e00\u4e9b\u64cd\u4f5c\u4e5f\u4f1a\u6539\u53d8\u6570\u636e\u7c7b\u578b\n\nvar result=num+str;\nconsole.log(result);\/\/100hello!,\u4e24\u8fb9\u6570\u636e\u7c7b\u578b\u4e0d\u7edf\u4e00\uff0c\u8fd9\u91cc+\u8868\u793a\u5b57\u7b26\u4e32\u62fc\u63a5\u4e0d\u662f\u52a0\u53f7\uff0cnum\u53d8\u6210\u4e86string\u7c7b\u578b\uff0c\u62fc\u63a5\u4e00\u8d77100hello!\n\n\/\/sting\u8f6c\u6570\u5b57\uff0c\u4f7f\u7528parseInt(),parseFloat()\nvar strNum=&#039;123&#039;;\nconsole.log(parseInt(strNum)+100)\/\/223,<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\/\/\u57fa\u672c\u6570\u636e\u7c7b\u578b \/\/boolean,\u5e03\u5c14\u503c var visible = true;\/\/\u65e0\u9700\u5f15\u53f7 var is [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[21],"tags":[],"_links":{"self":[{"href":"http:\/\/www.henrycome.com\/wordpress\/wp-json\/wp\/v2\/posts\/892"}],"collection":[{"href":"http:\/\/www.henrycome.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.henrycome.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.henrycome.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.henrycome.com\/wordpress\/wp-json\/wp\/v2\/comments?post=892"}],"version-history":[{"count":1,"href":"http:\/\/www.henrycome.com\/wordpress\/wp-json\/wp\/v2\/posts\/892\/revisions"}],"predecessor-version":[{"id":893,"href":"http:\/\/www.henrycome.com\/wordpress\/wp-json\/wp\/v2\/posts\/892\/revisions\/893"}],"wp:attachment":[{"href":"http:\/\/www.henrycome.com\/wordpress\/wp-json\/wp\/v2\/media?parent=892"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.henrycome.com\/wordpress\/wp-json\/wp\/v2\/categories?post=892"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.henrycome.com\/wordpress\/wp-json\/wp\/v2\/tags?post=892"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}