<!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>
本文通过实例介绍了三种JavaScript函数的定义方式:函数声明、函数表达式及Function构造函数,并展示了如何调用这些函数。
148

被折叠的 条评论
为什么被折叠?



