{"id":4796,"date":"2023-01-05T10:21:15","date_gmt":"2023-01-05T02:21:15","guid":{"rendered":"https:\/\/badgameshow.com\/steven\/?p=4796"},"modified":"2023-01-05T10:21:15","modified_gmt":"2023-01-05T02:21:15","slug":"%e5%ad%b8%e7%bf%92typescript%e5%9f%ba%e6%9c%ac%e6%95%b8%e6%93%9a%e9%a1%9e%e5%9e%8b%ef%bc%8c%e6%8e%8c%e6%8f%a1%e7%a8%8b%e5%bc%8f%e9%96%8b%e7%99%bc%e7%9a%84%e5%9f%ba%e7%a4%8e","status":"publish","type":"post","link":"https:\/\/badgameshow.com\/steven\/typescript\/%e5%ad%b8%e7%bf%92typescript%e5%9f%ba%e6%9c%ac%e6%95%b8%e6%93%9a%e9%a1%9e%e5%9e%8b%ef%bc%8c%e6%8e%8c%e6%8f%a1%e7%a8%8b%e5%bc%8f%e9%96%8b%e7%99%bc%e7%9a%84%e5%9f%ba%e7%a4%8e\/","title":{"rendered":"\u5b78\u7fd2TypeScript\u57fa\u672c\u6578\u64da\u985e\u578b\uff0c\u638c\u63e1\u7a0b\u5f0f\u958b\u767c\u7684\u57fa\u790e"},"content":{"rendered":"<p><meta name=\"keywords\" content=\"TypeScript, \u57fa\u672c\u6578\u64da\u985e\u578b\"><\/p>\n<p>TypeScript \u662f\u4e00\u7a2e\u7531 Microsoft \u958b\u767c\u7684 JavaScript \u7684\u8d85\u96c6\uff0c\u5b83\u64c1\u6709\u66f4\u5f37\u5927\u7684\u529f\u80fd\uff0c\u4e5f\u652f\u63f4\u66f4\u591a\u7684\u57fa\u672c\u6578\u64da\u985e\u578b\u3002\u5728 TypeScript \u4e2d\uff0c\u6709\u516d\u7a2e\u57fa\u672c\u6578\u64da\u985e\u578b\uff0c\u5206\u5225\u662f\uff1aboolean\u3001number\u3001string\u3001null\u3001undefined \u548c symbol\u3002<\/p>\n<h2>Boolean \u985e\u578b<\/h2>\n<p>Boolean \u985e\u578b\u662f\u6700\u57fa\u672c\u7684\u6578\u64da\u985e\u578b\uff0c\u5b83\u53ea\u6709\u5169\u500b\u503c\uff1atrue \u548c false\u3002\u5b83\u53ef\u4ee5\u7528\u4f86\u8868\u793a\u4e00\u500b\u4e8b\u7269\u662f\u5426\u767c\u751f\uff0c\u6216\u662f\u4e00\u500b\u689d\u4ef6\u662f\u5426\u6210\u7acb\u3002\u4f8b\u5982\uff0c\u6211\u5011\u53ef\u4ee5\u7528\u5b83\u4f86\u5224\u65b7\u4e00\u500b\u6578\u5b57\u662f\u5426\u5927\u65bc 10\uff1a<\/p>\n<pre class=\"brush: javascript\">\nlet num = 5;\nlet isGreaterThan10 = num > 10; \/\/ false\n<\/pre>\n<h2>Number \u985e\u578b<\/h2>\n<p>Number \u985e\u578b\u662f\u7528\u4f86\u8868\u793a\u6578\u5b57\u7684\uff0c\u5b83\u53ef\u4ee5\u8868\u793a\u6574\u6578\u3001\u5c0f\u6578\u3001\u8ca0\u6578\u7b49\u3002\u5b83\u4e5f\u53ef\u4ee5\u8868\u793a\u7279\u6b8a\u7684\u6578\u5b57\uff0c\u4f8b\u5982 NaN\uff08Not a Number\uff09\u3001Infinity\uff08\u7121\u9650\u5927\uff09\u7b49\u3002\u4f8b\u5982\uff0c\u6211\u5011\u53ef\u4ee5\u7528\u5b83\u4f86\u8868\u793a\u4e00\u500b\u6578\u5b57\uff1a<\/p>\n<pre class=\"brush: javascript\">\nlet num = 10;\n<\/pre>\n<h2>String \u985e\u578b<\/h2>\n<p>String \u985e\u578b\u662f\u7528\u4f86\u8868\u793a\u6587\u5b57\u7684\uff0c\u5b83\u53ef\u4ee5\u8868\u793a\u4efb\u4f55\u6587\u5b57\uff0c\u5305\u62ec\u4e2d\u6587\u3001\u82f1\u6587\u3001\u65e5\u6587\u7b49\u3002\u4f8b\u5982\uff0c\u6211\u5011\u53ef\u4ee5\u7528\u5b83\u4f86\u8868\u793a\u4e00\u6bb5\u6587\u5b57\uff1a<\/p>\n<pre class=\"brush: javascript\">\nlet str = \"Hello World!\";\n<\/pre>\n<h2>Null \u985e\u578b<\/h2>\n<p>Null \u985e\u578b\u662f\u4e00\u7a2e\u7279\u6b8a\u7684\u6578\u64da\u985e\u578b\uff0c\u5b83\u53ea\u6709\u4e00\u500b\u503c\uff1anull\u3002\u5b83\u8868\u793a\u4e00\u500b\u7a7a\u503c\uff0c\u4ee3\u8868\u8457\u8a72\u8b8a\u6578\u6c92\u6709\u503c\u3002\u4f8b\u5982\uff0c\u6211\u5011\u53ef\u4ee5\u7528\u5b83\u4f86\u8868\u793a\u4e00\u500b\u7a7a\u503c\uff1a<\/p>\n<pre class=\"brush: javascript\">\nlet empty = null;\n<\/pre>\n<h2>Undefined \u985e\u578b<\/h2>\n<p>Undefined \u985e\u578b\u4e5f\u662f\u4e00\u7a2e\u7279\u6b8a\u7684\u6578\u64da\u985e\u578b\uff0c\u5b83\u53ea\u6709\u4e00\u500b\u503c\uff1aundefined\u3002\u5b83\u8868\u793a\u4e00\u500b\u8b8a\u6578\u6c92\u6709\u88ab\u5b9a\u7fa9\uff0c\u6216\u8005\u8a72\u8b8a\u6578\u6c92\u6709\u88ab\u8ce6\u4e88\u4efb\u4f55\u503c\u3002\u4f8b\u5982\uff0c\u6211\u5011\u53ef\u4ee5\u7528\u5b83\u4f86\u8868\u793a\u4e00\u500b\u672a\u5b9a\u7fa9\u7684\u8b8a\u6578\uff1a<\/p>\n<pre class=\"brush: javascript\">\nlet notDefined;\nconsole.log(notDefined); \/\/ undefined\n<\/pre>\n<h2>Symbol \u985e\u578b<\/h2>\n<p>Symbol \u985e\u578b\u662f ES6 \u65b0\u589e\u7684\u6578\u64da\u985e\u578b\uff0c\u5b83\u53ef\u4ee5\u7528\u4f86\u8868\u793a\u4e00\u500b\u552f\u4e00\u7684\u503c\u3002\u5b83\u53ef\u4ee5\u7528\u4f86\u8868\u793a\u4e00\u500b\u7279\u6b8a\u7684\u503c\uff0c\u4f8b\u5982\u4e00\u500b\u7269\u4ef6\u7684\u552f\u4e00 ID\u3002\u4f8b\u5982\uff0c\u6211\u5011\u53ef\u4ee5\u7528\u5b83\u4f86\u8868\u793a\u4e00\u500b\u552f\u4e00\u7684\u503c\uff1a<\/p>\n<pre class=\"brush: javascript\">\nlet uniqueValue = Symbol();\n<\/pre>\n<p>\u4ee5\u4e0a\u5c31\u662f TypeScript \u4e2d\u7684\u516d\u7a2e\u57fa\u672c\u6578\u64da\u985e\u578b\uff0c\u5b83\u5011\u5206\u5225\u662f\uff1aboolean\u3001number\u3001string\u3001null\u3001undefined \u548c symbol\u3002\u5b83\u5011\u5404\u81ea\u6709\u8457\u4e0d\u540c\u7684\u7528\u9014\uff0c\u53ef\u4ee5\u7528\u4f86\u8868\u793a\u4e0d\u540c\u7684\u503c\u3002\u56e0\u6b64\uff0c\u5728\u958b\u767c TypeScript \u61c9\u7528\u7a0b\u5f0f\u6642\uff0c\u8981\u7279\u5225\u6ce8\u610f\u9019\u516d\u7a2e\u57fa\u672c\u6578\u64da\u985e\u578b\u7684\u4f7f\u7528\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5b78\u7fd2TypeScript\u57fa\u672c\u6578\u64da\u985e\u578b\uff0c\u53ef\u4ee5\u8b93\u4f60\u66f4\u52a0\u719f\u6089\u7a0b\u5f0f\u958b\u767c\u7684\u57fa\u790e\uff0c\u638c\u63e1TypeScript\u7684\u57fa\u672c\u6578\u64da\u985e\u578b\uff0c\u53ef\u4ee5\u8b93\u4f60\u66f4\u52a0\u719f\u6089\u7a0b\u5f0f\u958b\u767c\u7684\u57fa\u790e\uff0c\u66f4\u52a0\u4e86\u89e3\u7a0b\u5f0f\u958b\u767c\u7684\u57fa\u672c\u6982\u5ff5\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[187],"tags":[186],"class_list":["post-4796","post","type-post","status-publish","format-standard","hentry","category-typescript","tag-typescript"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack-related-posts":[],"jetpack_shortlink":"https:\/\/wp.me\/pcFK27-1fm","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/4796","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/comments?post=4796"}],"version-history":[{"count":1,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/4796\/revisions"}],"predecessor-version":[{"id":4797,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/4796\/revisions\/4797"}],"wp:attachment":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/media?parent=4796"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/categories?post=4796"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/tags?post=4796"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}