一天JavaScript示例-在功能上的标量参数和数组参数的差异

<!DOCTYPE>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>每天一个JavaScript实例-标量參数和数组參数的功能性差别</title>
<script>
	window.onload = function(){
		var items  = new Array('apple','orange','cherry','lime');
		var sep = "*";
		func(items,sep);
		console.log(items);
		console.log(sep);
		}
		function func(strings,separator){
			var result = "";
			//console.log(strings.length);
			for(var i = 0; i < strings.length; i++){
					result+=  strings[i] + separator;
				}
					separator = result;
					strings[strings.length] = result;
					
			}
</script>
</head>

<body>
</body>
</html>

posted @ 2015-12-14 09:49  hrhguanli  阅读(249)  评论(0编辑  收藏  举报