Javascript 中的 with

如下:

<!DOCTYPE html>
<html>
  <head>
    <title>js2.html</title>
  </head>
  
  <body>
    <script type="text/javascript">
    with (document)
    {    
        write("<ol>");
        write("<li>hello</li>");
        write("<li>world</li>");
        write("<li>hello world</li>");
        write("</ol>");
    }    
    </script>
    <br>
  </body>
</html>

结果:

  1. hello
  2. world
  3. hello world
原文地址:https://www.cnblogs.com/backpacker/p/2610830.html