匿名函数

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>匿名函数</title>
<!--了解匿名函数的定义
了解匿名函数的调用
理解匿名函数的作用
理解调用运算符“()”的作用-->
</head>
<body>
<script type="text/javascript">
/* function run(){
return 100;
}
document.write(run());
document.write("<br />")
document.write(run);
run(); 了解运算符()的作用,此处输出为:100
function run(){ return 100; }*/


/* 匿名函数的创建于调用*/
var noneName=function(){
document.write("调用匿名函数1<br />")
}
noneName();

(function(){
document.write("调用匿名函数2")
})();



输出: 调用匿名函数1
调用匿名函数2
</script>
</body>
</html>

函数名是函数对像地址的引用

“()运算符的作用是开始调用函数,也就是执行内存中的函数体,()内可加载参数。jsp中,函数调用的形式为:函数地址+(参数)

(function(){

})这样的风格也满足:函数地址+(参数)的格式

posted @ 2017-10-27 15:09  我喜欢喝糖水  阅读(158)  评论(0编辑  收藏  举报
我喜欢喝糖水的博客友链:股票指标编程学习