您当前的位置: 首页 > 

暂无认证

  • 2浏览

    0关注

    92582博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

JS匿名函数核心 16

发布时间:2020-08-04 00:13:49 ,浏览量:2

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>JS匿名函数核心 16</title> </head> <body> <script> /*
        1.什么是匿名函数?
        匿名函数就是没有名称的函数
		*/ //第一作为其他函数的参数 /*function say(fn)//fn=
	{
		fn();
		//这一步相当于
		function()
		{
			console.log("hello  world");
		}();
		//注意点就是必须在匿名函数的前后加上小括号。这是写法.
	}
	say(function()
	{
		console.log("hello  world");
	});*/ //解析:..... /*(function()
	{
		console.log("hello  world");
	})();*/ //第二作为其他函数的返回值 /*
        function test() {
            return function () {
                console.log("hello lnj");
            };
        }
        let fn = test(); // let fn = say;
        fn();
        */ //下面为解析,加个变量即可: function test() { let say= function () { console.log("hello lnj"); }; return say; } let fn = test(); // let fn = say; fn();//这一步相当于 (function () { console.log("hello lnj"); })(); //完成 </script> </body> </html> 
关注
打赏
1653961664
查看更多评论
立即登录/注册

微信扫码登录

0.0880s