JSP(对象专用语句)

来源:岁月联盟 编辑:exp 时间:2012-09-14

1,whit
[html] 
<html> 
<script language="javascript"> 
     
    var current_time = new Date(); 
 
    /* 
    用with 不需要为每次的方法调用指定对象 
    */ 
    whit(current_time) 
    { 
        var strDate=getYear()+"-"; 
        strDate +=getMonth()+"-"; 
        strDate +=getDate(); 
        alert(DatStr); 
    } 
     
</script> 
</html> 

2,for ... in: 遍历
[html] 
<html> 
<script language="javascript"> 
     
    function Person() 
    { 
        this.name="zxx"; 
        this.age=12; 
        this.height=176; 
    } 
 
    var p1 = new Person(); 
    var prop,str=""; 
    for(prop in p1)  
    { 
        str +=prop + " "; 
    } 
    alert(str); 
     
</script> 
</html>