java学习

java学习

 

js笔记

1.得到访问的文件地址

 <script type="text/javascript">
   
        with(location){
            var qs = search.substring(1);
            var hostName = hostname;      //unavailable when viewing from a local file
            var url = href;
        }

        alert(qs);
        alert(hostName);
        alert(url);

 

    </script>

<script type="text/javascript">
          //  == 表示两个对象的toString相等
//===表示两个对象的类型相等且值相等。
        alert(null == undefined);    //true
        alert(null === undefined);   //false
       
        alert("NaN" == NaN);        //false
        alert("NaN" === NaN);       //false
        alert(NaN == NaN);          //false
        alert(NaN === NaN);         //false
        alert(NaN != NaN);          //true
        alert(NaN !== NaN);         //true
       
        alert(false == 0);          //true
        alert(false === 0);         //false
        alert(true == 1);           //true
        alert(true === 1);          //false
       
        alert(null == 0);           //false
        alert(undefined == 0);      //false
       
        alert(5 == "5");            //true
        alert(5 === "5");           //false               
    </script>

 

--

<script type="text/javascript">
           
        alert(null == undefined);    //true
        alert(null === undefined);   //false
       
        alert("NaN" == NaN);        //false
        alert("NaN" === NaN);       //false
        alert(NaN == NaN);          //false
        alert(NaN === NaN);         //false
        alert(NaN != NaN);          //true
        alert(NaN !== NaN);         //true
       
        alert(false == 0);          //true
        alert(false === 0);         //false
        alert(true == 1);           //true
        alert(true === 1);          //false
       
        alert(null == 0);           //false
        alert(undefined == 0);      //false
       
        alert(5 == "5");            //true
        alert(5 === "5");           //false               

    </script>

<script type="text/javascript">
           
        var result1 = ("55" != 55);    //false ?equal because of conversion
        var result2 = ("55" !== 55);   //true ?not equal because different data types
        alert(result1);
        alert(result2);       

 var result1 = ("55" == 55);    //true ?equal because of conversion
        var result2 = ("55" === 55);   //false ?not equal because different data types           

    </script>
得到window中所有的事件

 

 <script type="text/javascript">
        for (var propName in window) {
             document.write(propName);
             document.write("<br />");
        }


    </script>


 <script type="text/javascript">
        for (var propName in window) {
             document.write(propName);
             document.write("<br />");
        }


    </script>

方法参数数组

 

<script type="text/javascript">
        function sayHi() {
            alert("Hello " + arguments[0] + ", " + arguments[1]);
        }

        sayHi("Nicholas", "how are you today?");


 function howManyArgs() {
            alert(arguments.length);
        }
       
        howManyArgs("string", 45);    //2
        howManyArgs();                //0
        howManyArgs(12);              //1    </script>


<script type="text/javascript">
        function sayHi() {
            alert("Hello " + arguments[0] + ", " + arguments[1]);
        }

        sayHi("Nicholas", "how are you today?");
    </script>

null的类型

<script type="text/javascript">
         
        var car = null;
        alert(typeof car);   //"object"
             


 alert(null == undefined);   //true    </script>

--

<script type="text/javascript">
         
        var car = null;
        alert(typeof car);   //"object"
             
    </script>

 

 

 

posted on 2013-08-05 16:15 杨军威 阅读(153) 评论(0)  编辑  收藏


只有注册用户登录后才能发表评论。


网站导航:
 

导航

统计

常用链接

留言簿

随笔档案

搜索

最新评论

阅读排行榜

评论排行榜