{"id":3112,"date":"2024-11-10T14:39:22","date_gmt":"2024-11-10T06:39:22","guid":{"rendered":"https:\/\/fwq.ai\/blog\/3112\/"},"modified":"2024-11-10T14:39:22","modified_gmt":"2024-11-10T06:39:22","slug":"typescript%e5%b8%b8%e7%94%a8%e7%9a%84%e6%96%b9%e6%b3%95%e6%9c%89%e5%93%aa%e4%ba%9b","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/3112\/","title":{"rendered":"typescript\u5e38\u7528\u7684\u65b9\u6cd5\u6709\u54ea\u4e9b"},"content":{"rendered":"<blockquote><p>\n  typescript \u5e38\u7528\u65b9\u6cd5\u5305\u62ec\uff1aobject.assign(): \u590d\u5236\u6216\u5408\u5e76\u5bf9\u8c61\u3002object.freeze(): \u51bb\u7ed3\u5bf9\u8c61\u4f7f\u5176\u4e0d\u53ef\u66f4\u6539\u3002object.keys(): \u8fd4\u56de\u5bf9\u8c61\u5c5e\u6027\u540d\u79f0\u6570\u7ec4\u3002array.from(): \u5c06\u53ef\u8fed\u4ee3\u5bf9\u8c61\u8f6c\u6362\u4e3a\u6570\u7ec4\u3002array.filter(): \u7b5b\u9009\u5e76\u8fd4\u56de\u6ee1\u8db3\u6761\u4ef6\u7684\u5143\u7d20\u3002array.map(): \u5904\u7406\u5e76\u8fd4\u56de\u6bcf\u4e2a\u5143\u7d20\u7684\u65b0\u6570\u7ec4\u3002string.slice(): \u63d0\u53d6\u5b50\u5b57\u7b26\u4e32\u3002promise.all(): \u7b49\u5f85\u6240\u6709 promise \u5b8c\u6210\u5e76\u8fd4\u56de\u7ed3\u679c\u3002promise.race\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202411\/08\/2024110801334669861.jpg\" class=\"aligncenter\" title=\"typescript\u5e38\u7528\u7684\u65b9\u6cd5\u6709\u54ea\u4e9b\u63d2\u56fe\" alt=\"typescript\u5e38\u7528\u7684\u65b9\u6cd5\u6709\u54ea\u4e9b\u63d2\u56fe\" \/><\/p>\n<p><strong>TypeScript \u5e38\u7528\u65b9\u6cd5<\/strong><\/p>\n<p><strong>\u5bf9\u8c61\u65b9\u6cd5<\/strong><\/p>\n<ul>\n<li>Object.assign(): \u590d\u5236\u5bf9\u8c61\u6216\u5408\u5e76\u591a\u4e2a\u5bf9\u8c61\u5230\u76ee\u6807\u5bf9\u8c61\u4e2d\u3002<\/li>\n<li>Object.freeze(): \u5c06\u5bf9\u8c61\u51bb\u7ed3\uff0c\u4f7f\u5176\u4e0d\u53ef\u66f4\u6539\u3002<\/li>\n<li>Object.keys(): \u8fd4\u56de\u5bf9\u8c61\u4e2d\u6240\u6709\u5c5e\u6027\u7684\u540d\u79f0\u6570\u7ec4\u3002<\/li>\n<li>Object.values(): \u8fd4\u56de\u5bf9\u8c61\u4e2d\u6240\u6709\u5c5e\u6027\u7684\u503c\u6570\u7ec4\u3002<\/li>\n<li>Object.entries(): \u8fd4\u56de\u5bf9\u8c61\u4e2d\u6240\u6709\u7684\u5143\u7ec4\u6570\u7ec4\u3002<\/li>\n<\/ul>\n<p><strong>\u6570\u7ec4\u65b9\u6cd5<\/strong><\/p>\n<ul>\n<li>Array.from(): \u5c06\u8f6c\u6362\u4e3a\u6570\u7ec4\u3002<\/li>\n<li>Array.of(): \u521b\u5efa\u4e00\u4e2a\u5305\u542b\u4e00\u4e2a\u6216\u591a\u4e2a\u5143\u7d20\u7684\u65b0\u6570\u7ec4\u3002<\/li>\n<li>Array.concat(): \u5408\u5e76\u4e24\u4e2a\u6216\u591a\u4e2a\u6570\u7ec4\u3002<\/li>\n<li>Array.filter(): \u521b\u5efa\u4e00\u4e2a\u65b0\u6570\u7ec4\uff0c\u5176\u4e2d\u5305\u542b\u901a\u8fc7\u6307\u5b9a\u6761\u4ef6\u7b5b\u9009\u540e\u7684\u5143\u7d20\u3002<\/li>\n<li>Array.map(): \u521b\u5efa\u4e00\u4e2a\u65b0\u6570\u7ec4\uff0c\u5176\u4e2d\u5305\u542b\u539f\u6570\u7ec4\u4e2d\u6bcf\u4e2a\u5143\u7d20\u5904\u7406\u540e\u7684\u503c\u3002<\/li>\n<\/ul>\n<p><strong>\u51fd\u6570\u65b9\u6cd5<\/strong><\/p>\n<ul>\n<li>Function.bind(): \u5c06\u51fd\u6570\u7ed1\u5b9a\u5230\u4e00\u4e2a\u7279\u5b9a\u4e0a\u4e0b\u6587\u3002<\/li>\n<li>Function.call(): \u4ee5\u4e00\u4e2a\u7279\u5b9a\u4e0a\u4e0b\u6587\u8c03\u7528\u51fd\u6570\u3002<\/li>\n<li>Function.apply(): \u4ee5\u4e00\u4e2a\u7279\u5b9a\u4e0a\u4e0b\u6587\u8c03\u7528\u51fd\u6570\uff0c\u5e76\u4f20\u9012\u53c2\u6570\u6570\u7ec4\u3002<\/li>\n<\/ul>\n<p><strong>\u5b57\u7b26\u4e32\u65b9\u6cd5<\/strong><\/p>\n<ul>\n<li>String.slice(): \u4ece\u5b57\u7b26\u4e32\u4e2d\u63d0\u53d6\u5b50\u5b57\u7b26\u4e32\u3002<\/li>\n<li>String.substr(): \u4ece\u5b57\u7b26\u4e32\u4e2d\u63d0\u53d6\u5b50\u5b57\u7b26\u4e32\u3002<\/li>\n<li>String.substring(): \u4ece\u5b57\u7b26\u4e32\u4e2d\u63d0\u53d6\u5b50\u5b57\u7b26\u4e32\u3002<\/li>\n<li>String.concat(): \u5408\u5e76\u4e24\u4e2a\u6216\u591a\u4e2a\u5b57\u7b26\u4e32\u3002<\/li>\n<li>String.replace(): \u7528\u53e6\u4e00\u4e2a\u5b57\u7b26\u4e32\u66ff\u6362\u5b57\u7b26\u4e32\u4e2d\u7684\u6307\u5b9a\u6a21\u5f0f\u3002<\/li>\n<\/ul>\n<p><strong>\u5176\u4ed6\u6709\u7528\u65b9\u6cd5<\/strong><\/p>\n<ul>\n<li>Promise.all(): \u7b49\u5f85\u591a\u4e2a Promise \u5e76\u8fd4\u56de\u4e00\u4e2a\u5305\u542b\u6240\u6709\u7ed3\u679c\u7684 Promise\u3002<\/li>\n<li>Promise.race(): \u7b49\u5f85\u591a\u4e2a Promise \u4e2d\u6700\u5feb\u7684\u4e00\u4e2a\u5b8c\u6210\uff0c\u5e76\u8fd4\u56de\u5176\u7ed3\u679c\u3002<\/li>\n<li>setInterval(): \u4ee5\u6307\u5b9a\u7684\u95f4\u9694\u4ee5\u6beb\u79d2\u4e3a\u5355\u4f4d\u5faa\u73af\u6267\u884c\u51fd\u6570\u3002<\/li>\n<li>setTimeout(): \u5728\u6307\u5b9a\u7684\u5ef6\u65f6\u540e\u6267\u884c\u51fd\u6570\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5e38\u7528\u7684\u65b9\u6cd5\u6709\u54ea\u4e9b\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>typescript \u5e38\u7528\u65b9\u6cd5\u5305\u62ec\uff1aobject.assign(): \u590d\u5236\u6216\u5408\u5e76\u5bf9\u8c61\u3002object.freeze(): \u51bb\u7ed3\u5bf9\u8c61\u4f7f\u5176\u4e0d\u53ef\u66f4\u6539\u3002object.keys(): \u8fd4\u56de\u5bf9\u8c61\u5c5e\u6027\u540d\u79f0\u6570\u7ec4\u3002array.from(): \u5c06\u53ef\u8fed\u4ee3\u5bf9\u8c61\u8f6c\u6362\u4e3a\u6570\u7ec4\u3002array.filter(): \u7b5b\u9009\u5e76\u8fd4\u56de\u6ee1\u8db3\u6761\u4ef6\u7684\u5143\u7d20\u3002array.map(): \u5904\u7406\u5e76\u8fd4\u56de\u6bcf\u4e2a\u5143\u7d20\u7684\u65b0\u6570\u7ec4\u3002string.slice(): \u63d0\u53d6\u5b50\u5b57\u7b26\u4e32\u3002promise.all(): \u7b49\u5f85\u6240\u6709 promise \u5b8c\u6210\u5e76\u8fd4\u56de\u7ed3\u679c\u3002promise.race TypeScript \u5e38\u7528\u65b9\u6cd5 \u5bf9\u8c61\u65b9\u6cd5 Object.assign(): \u590d\u5236\u5bf9\u8c61\u6216\u5408\u5e76\u591a\u4e2a\u5bf9\u8c61\u5230\u76ee\u6807\u5bf9\u8c61\u4e2d\u3002 Object.freeze(): \u5c06\u5bf9\u8c61\u51bb\u7ed3\uff0c\u4f7f\u5176\u4e0d\u53ef\u66f4\u6539\u3002 Object.keys(): \u8fd4\u56de\u5bf9\u8c61\u4e2d\u6240\u6709\u5c5e\u6027\u7684\u540d\u79f0\u6570\u7ec4\u3002 Object.values(): \u8fd4\u56de\u5bf9\u8c61\u4e2d\u6240\u6709\u5c5e\u6027\u7684\u503c\u6570\u7ec4\u3002 Object.entries(): \u8fd4\u56de\u5bf9\u8c61\u4e2d\u6240\u6709\u7684\u5143\u7ec4\u6570\u7ec4\u3002 \u6570\u7ec4\u65b9\u6cd5 Array.from(): \u5c06\u8f6c\u6362\u4e3a\u6570\u7ec4\u3002 Array.of(): \u521b\u5efa\u4e00\u4e2a\u5305\u542b\u4e00\u4e2a\u6216\u591a\u4e2a\u5143\u7d20\u7684\u65b0\u6570\u7ec4\u3002 Array.concat(): \u5408\u5e76\u4e24\u4e2a\u6216\u591a\u4e2a\u6570\u7ec4\u3002 Array.filter(): \u521b\u5efa\u4e00\u4e2a\u65b0\u6570\u7ec4\uff0c\u5176\u4e2d\u5305\u542b\u901a\u8fc7\u6307\u5b9a\u6761\u4ef6\u7b5b\u9009\u540e\u7684\u5143\u7d20\u3002 Array.map(): \u521b\u5efa\u4e00\u4e2a\u65b0\u6570\u7ec4\uff0c\u5176\u4e2d\u5305\u542b\u539f\u6570\u7ec4\u4e2d\u6bcf\u4e2a\u5143\u7d20\u5904\u7406\u540e\u7684\u503c\u3002 \u51fd\u6570\u65b9\u6cd5 Function.bind(): \u5c06\u51fd\u6570\u7ed1\u5b9a\u5230\u4e00\u4e2a\u7279\u5b9a\u4e0a\u4e0b\u6587\u3002 Function.call(): \u4ee5\u4e00\u4e2a\u7279\u5b9a\u4e0a\u4e0b\u6587\u8c03\u7528\u51fd\u6570\u3002 Function.apply(): \u4ee5\u4e00\u4e2a\u7279\u5b9a\u4e0a\u4e0b\u6587\u8c03\u7528\u51fd\u6570\uff0c\u5e76\u4f20\u9012\u53c2\u6570\u6570\u7ec4\u3002 \u5b57\u7b26\u4e32\u65b9\u6cd5 String.slice(): \u4ece\u5b57\u7b26\u4e32\u4e2d\u63d0\u53d6\u5b50\u5b57\u7b26\u4e32\u3002 String.substr(): \u4ece\u5b57\u7b26\u4e32\u4e2d\u63d0\u53d6\u5b50\u5b57\u7b26\u4e32\u3002 String.substring(): \u4ece\u5b57\u7b26\u4e32\u4e2d\u63d0\u53d6\u5b50\u5b57\u7b26\u4e32\u3002 String.concat(): \u5408\u5e76\u4e24\u4e2a\u6216\u591a\u4e2a\u5b57\u7b26\u4e32\u3002 String.replace(): \u7528\u53e6\u4e00\u4e2a\u5b57\u7b26\u4e32\u66ff\u6362\u5b57\u7b26\u4e32\u4e2d\u7684\u6307\u5b9a\u6a21\u5f0f\u3002 \u5176\u4ed6\u6709\u7528\u65b9\u6cd5 [&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-3112","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/3112","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=3112"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/3112\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=3112"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=3112"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=3112"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}