首页 > 其他 > 详细

with语句

时间:2016-07-31 18:59:36      阅读:291      评论:0      收藏:0      [点我收藏+]

 

<script type="text/javascript">
/*
    with语句:有了 With 语句,在存取对象属性和调用方法时就不用重复指定对象。

    
    格式:
        with(对象){
            
            
                
        }

    

*/

    with(document){
        for(var i = 0 ; i<5; i++){
            
            for(var j  =0 ; j<=i ; j++){
                write("*&nbsp;");    
            }    
            write("<br/>");
        }
        write("<hr/>");
    }


    function Person(id , name){
        this.id = id;
        this.name = name;    
    }
    
    //创建一个对象
    var  p = new Person(110,"狗娃");
    
    
    with(p){
        document.write("编号:"+ p.id);
        document.write("姓名:"+ name);
    }
    
    





</script>

 

with语句

原文:http://www.cnblogs.com/linst/p/5723496.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!