JavaScript函数三种定义形式

来源:互联网 发布:淘宝代充平台 编辑:程序博客网 时间:2024/06/05 11:43



<!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8">    <title>Study Fanction</title>    <script type="text/javascript" charset="utf-8">        //1. function语句式        function test1() {            window.document.write('test1...')        }        test1();        //2. ECMA recommend 函数直接量        var test2 = function () {            window.document.write('test2...');        }        test2();        //3. Function构造式        var test3 = new Function('a','b','return a+b;');        document.write(test3(10,20));        document.write('<br><br>');        document.write(test4);//        var test4 = function () {//            document.write('<br>'+'test2...');//        }    </script></head><body></body></html>




0 0