<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

    <title>01globalObject.html</title>

    <script>

        document.write("eval('1>2')=" + eval('1>2') + "<br>");//F

        document.write("isNaN('123a')=" + isNaN('123a') + "<br>");//T

        document.write("isNaN('a123')=" + isNaN('a123') + "<br>");//T

        document.write("isNaN('123.33')=" + isNaN('123') + "<br>");//F

        document.write("escape('123&chen@iii.org.tw')=" + escape('123&chen@iii.org.tw') + "<br>");

        //escape('123&chen@iii.org.tw')=123%26chen@iii.org.tw

        //escape已不建議使用,但是還是可以拿來解碼,例如用在中文上

        document.write("encodeURI('123&chen@iii.org.tw')=" + encodeURI('123&chen@iii.org.tw') + "<br>");

        //encodeURI('123&chen@iii.org.tw')=123&chen@iii.org.tw

        document.write("escape('中文')=" + escape('中文') + "<br>");

        //escape('中文')=%u4E2D%u6587

        document.write("unescape('%u4E2D%u6587')=" + unescape('%u4E2D%u6587') + "<br>");

        //unescape('%u4E2D%u6587')=中文

 

 

        document.write("<hr>")

        //練習:

        //目標:a1=b*c

        var b = 5, c = 6, n = 3;

        document.write(eval("a" + n + "=b*c") + "<br>")//30

        document.write(a3)//30,已記住變數

        //eval可以在()內用字串寫運算

 

    </script>

</head>

<body>

 

</body>

</html>

 

arrow
arrow
    全站熱搜

    乙方 發表在 痞客邦 留言(0) 人氣()