{"id":87,"date":"2012-02-13T22:53:30","date_gmt":"2012-02-13T14:53:30","guid":{"rendered":"https:\/\/blog.indeex.club\/?p=87"},"modified":"2020-06-20T22:48:03","modified_gmt":"2020-06-20T14:48:03","slug":"javascript-%e4%b8%ad%e7%9a%84with","status":"publish","type":"post","link":"https:\/\/blog.indeex.club\/index.php\/2012\/02\/13\/javascript-%e4%b8%ad%e7%9a%84with\/","title":{"rendered":"Javascript \u4e2d\u7684with"},"content":{"rendered":"<p>\u4eca\u5929\u6821\u95e8\u53e3\u7684\u65c5\u9986\u53c8\u8981\u3002\u3002\u3002\u7206\u6ee1\u4e86\u3002\u3002<\/p>\n<p>\u6c6a\u6c6a\u6c6a\uff01\uff01\uff01&#x1f436;&#x1f436;&#x1f436;&#x1f436;&#x1f436;&#x1f436;<\/p>\n<h4>with (object)  statements<\/h4>\n<p>** \u53c2\u6570 \uff1aobject **<\/p>\n<p>\u65b0\u7684\u9ed8\u8ba4\u5bf9\u8c61\u3002<\/p>\n<p>** statements **<\/p>\n<p>\u4e00\u4e2a\u6216\u591a\u4e2a\u8bed\u53e5\uff0cobject \u662f\u8be5\u8bed\u53e5\u7684\u9ed8\u8ba4\u5bf9\u8c61\u3002<\/p>\n<p><code>\u8bf4\u660e<\/code><\/p>\n<p>with \u8bed\u53e5\u901a\u5e38\u7528\u6765\u7f29\u77ed\u7279\u5b9a\u60c5\u5f62\u4e0b\u5fc5\u987b\u5199\u7684\u4ee3\u7801\u91cf\u3002\u5728\u4e0b\u9762\u7684\u4f8b\u5b50\u4e2d\uff0c\u8bf7\u6ce8\u610f Math \u7684\u91cd\u590d\u4f7f\u7528\uff1a<\/p>\n<pre><code class=\"line-numbers\">x = Math.cos(3 * Math.PI) + Math.sin(Math.LN10) \n\ny = Math.tan(14 * Math.E) \n<\/code><\/pre>\n<p>\u5f53\u4f7f\u7528 with \u8bed\u53e5\u65f6\uff0c\u4ee3\u7801\u53d8\u5f97\u66f4\u77ed\u4e14\u66f4\u6613\u8bfb\uff1a<\/p>\n<p>&#8220;`<br \/>\nwith (Math){<br \/>\nx = cos(3 * PI) + sin (LN10)<br \/>\ny = tan(14 * E)<br \/>\n}<br \/>\nwith(),,,;  <\/p>\n<p>with(document)write(fileSize),write(&#039;&lt;br&gt;&#039;+lastModified)<\/p>\n<p>&lt;pre&gt;&lt;code class=&quot;line-numbers&quot;&gt;&lt;\/code&gt;&lt;\/pre&gt;<\/p>\n<p>&lt;script&gt;<br \/>\n    with(document)<br \/>\n    write(fileSize), write(&#039;&lt;br&gt;&#039; + lastModified), write(&#039;&lt;br&gt;&#039; + location),<br \/>\n    write(&#039;&lt;br&gt;&#039; + protocol), write(&#039;&lt;br&gt;&#039; + location.host)<br \/>\n&lt;\/script&gt;<\/p>\n<p>&lt;pre&gt;&lt;code class=&quot;line-numbers&quot;&gt;\u907f\u514d\u4f7f\u7528JavaScript\u7684With<\/p>\n<p>JavaScript\u5141\u8bb8\u4f7f\u7528with\u5173\u952e\u5b57\u6765\u6307\u5b9a\u67d0\u4e2a\u5bf9\u8c61\u7684\u4e00\u7cfb\u5217\u5c5e\u6027\u6216\u8005\u65b9\u6cd5\u3002\u6bd4\u5982\u6709\u8fd9\u6837\u4e00\u6bb5\u4ee3\u7801\uff1a <\/p>\n<p>&lt;\/code&gt;&lt;\/pre&gt;<\/p>\n<p>var x = document.body.scrollLeft;<br \/>\ndocument.write(&#039;text1&#039;);<br \/>\ndocument.write(&#039;text2&#039;);<br \/>\ndocument.write(&#039;text3&#039;);<\/p>\n<p>&lt;pre&gt;&lt;code class=&quot;line-numbers&quot;&gt;\u5982\u679c\u7528with\u7684\u8bdd\uff0c\u53ef\u4ee5\u8fd9\u6837\u5199\uff1a <\/p>\n<p> &#8220;`<br \/>\nwith document {<br \/>\nvar x = body.scrollLeft;<br \/>\nwrite(&#8216;text1&#8217;);<br \/>\nwrite(&#8216;text2&#8217;);<br \/>\nwrite(&#8216;text3&#8217;);<br \/>\n}<br \/>\n<\/code><\/p>\n<p>\u4f46\u662f\uff0c\u8fd9\u6837\u770b\u4f3c\u7cbe\u7b80\u4ee3\u7801\u7684\u65b9\u6cd5\u5374\u4f1a\u4f7fJavaScript\u7684\u6267\u884c\u65f6\u95f4\u589e\u52a0\u8bb8\u591a\u3002\u56e0\u4e3a\u5b83\u4f1a\u53bb\u68c0\u67e5\u5927\u62ec\u53f7\u5185\u7684\u6bcf\u4e2a\u53d8\u91cf\u662f\u5426\u662f\u8fd9\u4e2a\u5bf9\u8c61\u7684\u5c5e\u6027\u6216\u8005\u65b9\u6cd5\u3002<\/p>\n<p>\u6240\u4ee5\uff0c\u5982\u679c\u8981\u7cbe\u7b80\u4ee3\u7801\u7684\u8bdd\uff0c\u53ef\u4ee5\u8fd9\u6837\u5199\uff0c\u4ece\u800c\u907f\u514d\u4f7f\u7528with\u3002<\/p>\n<pre><code class=\"line-numbers\">var d = document; \nvar x = d.body.scrollLeft; \nd.write('text1'); \nd.write('text2'); \nd.write('text3'); \n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u4eca\u5929\u6821\u95e8\u53e3\u7684\u65c5\u9986\u53c8\u8981\u3002\u3002\u3002\u7206\u6ee1\u4e86\u3002\u3002 \u6c6a\u6c6a\u6c6a\uff01\uff01\uff01&#x1f436;&#x1f436;&#038;#x1f43<a href=\"https:\/\/blog.indeex.club\/index.php\/2012\/02\/13\/javascript-%e4%b8%ad%e7%9a%84with\/\" class=\"read-more\">Read More<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[4],"_links":{"self":[{"href":"https:\/\/blog.indeex.club\/index.php\/wp-json\/wp\/v2\/posts\/87"}],"collection":[{"href":"https:\/\/blog.indeex.club\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.indeex.club\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.indeex.club\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.indeex.club\/index.php\/wp-json\/wp\/v2\/comments?post=87"}],"version-history":[{"count":1,"href":"https:\/\/blog.indeex.club\/index.php\/wp-json\/wp\/v2\/posts\/87\/revisions"}],"predecessor-version":[{"id":88,"href":"https:\/\/blog.indeex.club\/index.php\/wp-json\/wp\/v2\/posts\/87\/revisions\/88"}],"wp:attachment":[{"href":"https:\/\/blog.indeex.club\/index.php\/wp-json\/wp\/v2\/media?parent=87"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.indeex.club\/index.php\/wp-json\/wp\/v2\/categories?post=87"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.indeex.club\/index.php\/wp-json\/wp\/v2\/tags?post=87"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}