利用arguments.callee写递归匿名函数
<html>
<head>
<title>arguments callee test</title>
</head>
<body>
<script type="text/javascript" charset="utf-8">
var factorial = function(x) {
if (x == 1) {
return 1;
} else {
return x * arguments.callee(x - 1);
}
};
document.write(factorial(5));
</script>
</body>
</html>
No comments :
Post a Comment