日期:2014-05-16  浏览次数:20260 次

一些简单的JS的例子
<script type="text/javascript"> 
//(function(){})()就是將裏面的函數作為一個整體拿上執行,则就执行里面的,输出1,然后返回值也是一个执行,如果偏要返回一个函数指针则怎么办???
/*
(function(){
alert(1);
return (function(){alert(2);
this.play=function(){alert("play");},
this.study=function(){alert("study");}
})()
})()
*/

/*
function abc(){
alert(11);
return function(){alert(22);
this.play=function(){alert("play");},
this.study=function(){alert("study");}
}
}

(abc())()//函数的执行结果又是一个函数,将结果再给执行一遍 就OK了
*/

/*
function def(){
return {
play:function(){alert("play");},
study:function(){alert("study");}
};
}
def().play();//执行的结果是个对象,再拿这个对象执行对象的方法就可以了
*/


</script> 
<script type="text/javascript">
//(function (msg){alert(msg);})("1234556");
</script>