{"id":1932,"date":"2023-03-25T14:26:38","date_gmt":"2023-03-25T06:26:38","guid":{"rendered":""},"modified":"2023-03-25T14:26:38","modified_gmt":"2023-03-25T06:26:38","slug":"ES6 void \u5173\u952e\u5b57","status":"publish","type":"post","link":"https:\/\/bianchenghao6.com\/1932.html","title":{"rendered":"ES6 void \u5173\u952e\u5b57"},"content":{"rendered":"


\n <\/head>
\n <\/p>\n

\n

ES6 void \u5173\u952e\u5b57<\/h1>\n<\/p><\/div>\n

ES6 void \u5173\u952e\u5b57<\/h2>\n
\n void \u5173\u952e\u5b57\u7528\u4f5c\u4e0d\u8fd4\u56de\u4efb\u4f55\u503c\u7684\u51fd\u6570\u7684\u8fd4\u56de\u7c7b\u578b\u3002\u5b83\u8bc4\u4f30\u7ed9\u5b9a\u7684\u8868\u8fbe\u5f0f\u5e76\u8fd4\u56de undefined\u3002\u5b83\u662f\u4e00\u4e2a\u91cd\u8981\u7684 JavaScript \u5173\u952e\u5b57\uff0c\u53ef\u7528\u4f5c\u4e00\u5143\u8fd0\u7b97\u7b26\u5e76\u51fa\u73b0\u5728\u4efb\u4f55\u7c7b\u578b\u7684\u5355\u4e2a\u64cd\u4f5c\u6570\u4e4b\u524d\u3002 p> <\/p>\n
\n \u5b83\u6307\u5b9a\u8981\u8ba1\u7b97\u7684\u8868\u8fbe\u5f0f\u800c\u4e0d\u8fd4\u56de\u4efb\u4f55\u503c\u3002 void \u8fd0\u7b97\u7b26\u901a\u5e38\u7528\u4e8e\u83b7\u53d6 undefined \u539f\u59cb\u503c\u3002\n <\/div>\n
\n \u8bed\u6cd5\n <\/div>\n
\n
\nvoid expression<\/pre>\n

<\/code>\n <\/div>\n

\n \u793a\u4f8b\n <\/div>\n
\n
\nvar <\/span>x,y,z;  \nx = void <\/span>( y = 50, z = 70 );\nconsole.log<\/span>('x = '<\/span> + x + ' y = '<\/span> + y +' z = '<\/span> + z );<\/pre>\n

<\/code>\n <\/div>\n

\n \u8f93\u51fa\n <\/div>\n
\n
x = undefined y = 50 z = 70<\/pre>\n

<\/code>\n <\/div>\n

\u7acb\u5373\u8c03\u7528\u7684\u51fd\u6570\u8868\u8fbe\u5f0f(IIFE) \u548c void \u5173\u952e\u5b57<\/h2>\n
\n \u4f7f\u7528 IIFE\uff0cvoid \u53ef\u7528\u4e8e\u5f3a\u5236\u5c06\u51fd\u6570\u5173\u952e\u5b57\u89c6\u4e3a\u8868\u8fbe\u5f0f\u800c\u4e0d\u662f\u58f0\u660e.\n <\/div>\n
\n \u793a\u4f8b\n <\/div>\n
\n
\nvoid function hello() { \n   var <\/span>msg = function () \n   {console.log<\/span>(\"Welcome back!!\"<\/span>)}; \n   msg(); \n}();<\/pre>\n

<\/code>\n <\/div>\n

\n \u8f93\u51fa\n <\/div>\n
\n
Welcome back!!<\/pre>\n

<\/code>\n <\/div>\n

JavaScript URI \u548c void \u5173\u952e\u5b57<\/h2>\n
\n \u5f53\u6d4f\u89c8\u5668\u8ddf\u968f URI \u65f6\uff0c\u5b83\u4f1a\u8bc4\u4f30 URI \u4ee3\u7801\u5e76\u7528\u8fd4\u56de\u503c\u66ff\u6362\u9875\u9762\u5185\u5bb9\uff0c\u9664\u975e\u8be5\u503c\u672a\u5b9a\u4e49\u3002 JavaScript: URI \u662f HTML \u9875\u9762\u4e2d\u5e7f\u6cdb\u4f7f\u7528\u7684\u8bed\u6cd5\u3002\n <\/div>\n
\n void \u8fd0\u7b97\u7b26\u53ef\u7528\u4e8e\u8fd4\u56de undefined > \u503c\u3002\n <\/div>\n
\n \u8ba9\u6211\u4eec\u7406\u89e3\u76f8\u540c\u7684\u8bf4\u660e\u3002\n <\/div>\n
\n \u793a\u4f8b\n <\/div>\n
\n \u5728\u4e0b\u9762\u7684\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u6b63\u5728\u5b9a\u4e49\u4e24\u4e2a\u5e26\u6709\u8b66\u544a\u6846\u7684\u94fe\u63a5\u3002\u5728\u4e00\u4e2a\u94fe\u63a5\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528\u4e86 void \u5173\u952e\u5b57\u3002\u5f53\u76f8\u5e94\u7684\u94fe\u63a5\u88ab\u70b9\u51fb\u65f6\uff0c\u5b83\u4f1a\u8bc4\u4f30 JavaScript \u8b66\u62a5\u5e76\u5c06\u5176\u4f20\u9012\u7ed9 void() \u8fd0\u7b97\u7b26\u3002 void() \u8fd0\u7b97\u7b26\u5c06\u8fd4\u56de\u4e00\u4e2a\u672a\u5b9a\u4e49\u7684\u503c\u3002\u56e0\u6b64\uff0c\u8b66\u62a5\u529f\u80fd\u5c06\u4e0d\u4f1a\u663e\u793a\u5728\u9875\u9762\u4e0a\u3002\n <\/div>\n
\n \u5f53\u60a8\u5355\u51fb\u7b2c\u4e8c\u4e2a\u94fe\u63a5\u65f6\uff0c\u5b83\u5c06\u663e\u793a\u4e00\u4e2a\u8b66\u62a5\u5bf9\u8bdd\u6846\u3002\n <\/div>\n
\n
\nhtml> \n<head>  \n<\/head> \n<body> \n    <center> \n        <h1>Hello World :) :)<\/h1> \n        <h2>Welcome to lidihuo<\/h2> \n        <h2>Click the following links to see the changes<\/h2> \n        <a href = \"javascript:void(javascript:alert('<\/span>hello world!!'))\"<\/span>> \n            It will do <\/span>nothing.\n          <\/a> \n          <br\/><br\/>\n          <a href = \"javascript:alert('<\/span>Welcome to lidihuo');\"<\/span>>Click here for <\/span>an alert<\/a>\n    <\/center> \n<\/body> \n  \n<\/html><\/pre>\n

<\/code>\n <\/div>\n

\n \u8f93\u51fa\n <\/div>\n
\n \u6210\u529f\u6267\u884c\u4ee5\u4e0a\u4ee3\u7801\u540e\uff0c\u4f1a\u5f97\u5230\u5982\u4e0b\u8f93\u51fa:\n <\/div>\n

ES6 void \u5173\u952e\u5b57_https:\/\/bianchenghao6.com_\u3010ES6 \u6559\u7a0b\u3011_\u7b2c1\u5f20 <\/p>\n

\n \u5f53\u4f60\u70b9\u51fb\u7b2c\u4e00\u4e2a\u94fe\u63a5\u65f6\uff0c\u4f60\u4ec0\u4e48\u4e5f\u5f97\u4e0d\u5230\u3002\u4f46\u662f\uff0c\u5355\u51fb\u7b2c\u4e8c\u4e2a\u94fe\u63a5\u65f6\uff0c\u60a8\u5c06\u770b\u5230\u4ee5\u4e0b\u5c4f\u5e55:\n <\/div>\n

ES6 void \u5173\u952e\u5b57_https:\/\/bianchenghao6.com_\u3010ES6 \u6559\u7a0b\u3011_\u7b2c2\u5f20\n <\/div>\n

\n << Python \u8bed\u6cd5
\n Python \u53d8\u91cf >>\n <\/div>\n

<\/body>
\n<\/html><\/p>\n","protected":false},"excerpt":{"rendered":"ES6 void \u5173\u952e\u5b57zh-cn","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[161],"tags":[],"class_list":["post-1932","post","type-post","status-publish","format-standard","hentry","category-es6jc"],"_links":{"self":[{"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/posts\/1932"}],"collection":[{"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/comments?post=1932"}],"version-history":[{"count":0,"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/posts\/1932\/revisions"}],"wp:attachment":[{"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/media?parent=1932"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/categories?post=1932"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/tags?post=1932"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}