226, javaScript objects --- Global Object

Golbal object. Global object, it inside the method can be used directly, without the need for an object, direct write method name ()
a more commonly used method
    1,
        decodeURI () decoding an encoded URI.
        the encodeURI () is encoded as a string URI.
    
        decodeURIComponent () decodes an encoded URI. This encoded string more
        the encodeURIComponent () is encoded as a string URI.
    2,
        parserInt () the string into digital
            * plus + in front of a string - numbers can be transferred, but using parserInt () method, if the beginning of the string section contains digital (character encountered stops), the result will be returned this part numbers, not NaN.
    . 3,
        isNaN () determines whether a value is NaN. If you write: value == NaN, no matter what the value is, the result is false, even if it is NaN == NaN result is false, so use isNaN () method
    4,
        eval (): calculated JavaScript string, and put it as the script code to execute.
    Note: URI codec will mean when the page is transmitted, for example, special Chinese characters can not be directly transmitted, needs to be transmitted according to the relevant transcoded characters, called the codec behavior such transmission URI before / after.
    

    <script>
        var str = "中华人名共和国?#";
        var edu = encodeURI(str)
        document.write("edu:"+edu+ "<br>");
        var du = decodeURI(edu)
        document.write("du:"+du+ "<br>");

        var str1 = "中华人民共和国?#";
        var edu1 = encodeURI(str1)
        document.write("edu1:"+edu1+ "<br>");
        var du1 = decodeURI(edu1)
        document.write("du1:"+du1+ "<br>");

        document.write("<hr>");

        document.write("123abc:  "+parseInt("123abc")+"<br>");
        document.write("a123abc:  "+parseInt("a123abc")+"<br>");

        document.write("<hr>");

        document.write("isNaN(NaN)):  "+isNaN(NaN)+"<br>");
        var flag = NaN==NaN?true:false;
        document.write("NaN ==NaN):  "+flag+"<br>");

        document.write("<hr>");

        var sj = "alert('测试eval()方法')"
        eval(sj);
    </script>

 

发布了130 篇原创文章 · 获赞 5 · 访问量 1万+

Guess you like

Origin blog.csdn.net/l0510402015/article/details/104409399