JavaScript入门之函数的高级写法
2014-02-26 15:57
579 查看
1
<html>
<head>
<title>高数高级写法</title>
<script>
function square(x){return x * x};
var f = function(x){return x * x};
alert(f(5));
</script>
</head>
</html>
2
<html>
<head>
<title>高数高级写法</title>
<script>
var f = function square(x){
alert("***");
alert(square);
return x * x;
};
alert(f(5));
</script>
</head>
</html>
结果:
***
f = function square(x){
alert("***");
alert(square);
return x * x;
};
25
先调用函数里面的alert,然后在调用整体。
3.函数调用
<html>
<head>
<title>高数高级写法</title>
<script>
function setValue(x){return x + 10};
var f = function square(x){
return setValue(x) * setValue(x);
};
alert(f(5));
</script>
</head>
</html>
<html>
<head>
<title>高数高级写法</title>
<script>
function square(x){return x * x};
var f = function(x){return x * x};
alert(f(5));
</script>
</head>
</html>
2
<html>
<head>
<title>高数高级写法</title>
<script>
var f = function square(x){
alert("***");
alert(square);
return x * x;
};
alert(f(5));
</script>
</head>
</html>
结果:
***
f = function square(x){
alert("***");
alert(square);
return x * x;
};
25
先调用函数里面的alert,然后在调用整体。
3.函数调用
<html>
<head>
<title>高数高级写法</title>
<script>
function setValue(x){return x + 10};
var f = function square(x){
return setValue(x) * setValue(x);
};
alert(f(5));
</script>
</head>
</html>
相关文章推荐
- JavaScript 4.2 函数高级-this
- 当javaScript从入门到提高前需要注意的细节:函数部分
- javascript中函数的写法实例代码详解
- 函数高级写法
- javascript高级知识分析——作为对象的函数
- Javascript高级程序设计——函数声明与函数表达式的区别
- JavaScript高级程序设计之基本概念之函数第3.7讲笔记
- JavaScript 学习笔记十一 函数高级应用
- javascript 立即执行函数的写法
- 【JavaScript】 高级函数
- javascript中函数的5个高级技巧
- Javascript高级程序设计——this、闭包、函数表达式
- JavaScript高级程序设计之函数表达式之私有变量之模块模式第7.4.2讲笔记
- JavaScript中的高级函数
- javascript 按钮onclick事件中 函数1成功执行函数2写法
- javascript入门·向函数传递表单数据和元素(赠送一小技巧)
- JavaScript高级编程入门
- AJAX入门之深入理解JavaScript中的函数
- JavaScript高级程序设计笔记------函数
- JavaScript高级程序设计5--函数表达式