js匿名函数实现递归调用

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<script type="text/javascript">
		//求阶乘
		var a = (function (value) {
			if (value > 1)
				return value * arguments.callee (value - 1);
			return value;
		})(4);
	</script>
</head>
<body>
	<button onclick="alert(a)">萌萌哒</button>
</body>
</html>

你可能感兴趣的:(JavaScript,html5)