0
点赞
收藏
分享

微信扫一扫

js方法传参规则

_刘彦辉 2022-03-11 阅读 52

js方法传参规则:

一个萝卜一个坑的原则,萝卜多了没用坑,萝卜就会被舍弃

代码结果展示:

示例代码: 

<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>

	<body>
	</body>
	<script type="text/javascript">
		function test(a, b, c, d) {
			console.log("a:" + a + ",b:" + b + ",c:" + c + ",d:" + d);
		}
		test(1);
		test(1,2);
		test(1,2,3);
		test(1,2,3,4);
		test(1,2,3,4,5);
	</script>

</html>
举报

相关推荐

0 条评论