U E D R , A S I H C RSS

Java Script/2011년스터디/윤종하

Difference between r1.2 and the current

@@ -1,3 +1,6 @@
[[pagelist(^JavaScript/2011년스터디)]]
== 11일 ==
{{{
<html>
<head><title>파스칼의 삼각형 (Pascal's triangle by javascript)</title></head>
@@ -10,7 +13,7 @@
return val;
}
function combi(n,k){
return fac(n)/(fac(n-k+1)*fac(k))
return fac(n)/(fac(n-k)*fac(k))
}

var i,j;
@@ -19,9 +22,45 @@
for(j=0;j<=i;j++) documnet.write(combi(i,j)+" ");
document.write("<br>");
}
</body>
</script>
</script>
</body>
</html>
}}}

급한대로 파스칼의 삼각형 만들어서 if, for, 함수정의 공부한거 티내려고 했는데 안되네요 ㅠ
 
== 18일 ==
 
{{{
<html>
<head><title>Anonymous Function Test</title></head>
<body>
<script language="javascript" type="text/javascript">
// An element with an ID of main
var obj = document.getElementById("main");
 
// An array of items to bind to
var items = [ "click", "keypress" ];
 
// Iterate through each of the items
for (var i = 0; i < items.length; i++ ) {
// Use a self-executed anonymous function to induce scope
(function(){
// Remember the value within this scope
var item = items[i];
// Bind a function to the elment
obj[ "on" + item ] = function() {
// item refers to a parent variable that has been successfully
// scoped within the context of this for loop
alert( "Thanks for your " + item );
};
})();
}
</script>
</body>
</html>
}}}
 
[http://happyzoo.tistory.com/124 원본출처]
Anonymous Function에 대한 예제를 구해왔는데요.
scope 문제 때문에 소스가 잘 작동하지 않는거 같기도하고 헷갈려요;;



11일


<html> 
<head><title>파스칼의 삼각형 (Pascal's triangle by javascript)</title></head> 
	<body> 
		<script language="javascript" type="text/javascript">
			function fac(n){
				if(n==0)	return 1;
				var val=1;
				for(;n>0;n--) val*=n;
				return val;
			}
			function combi(n,k){
				return fac(n)/(fac(n-k)*fac(k))
			}
		
			var i,j;
			for(i=0;i<10;i++){
				for(j=0;j<10-i;j++)	document.write(" ");
				for(j=0;j<=i;j++)	documnet.write(combi(i,j)+" ");
				document.write("<br>");
			}
		</script>
	</body>
</html>

급한대로 파스칼의 삼각형 만들어서 if, for, 함수정의 공부한거 티내려고 했는데 안되네요 ㅠ

18일


<html>
<head><title>Anonymous Function Test</title></head>
	<body>
		<script language="javascript" type="text/javascript">
			// An element with an ID of main
			var obj = document.getElementById("main");

			// An array of items to bind to
			var items = [ "click", "keypress" ];

			// Iterate through each of the items
			for (var i = 0; i < items.length; i++ ) {
				// Use a self-executed anonymous function to induce scope
				(function(){
					// Remember the value within this scope
					var item = items[i];
					// Bind a function to the elment
					obj[ "on" + item ] = function() {
						// item refers to a parent variable that has been successfully
						// scoped within the context of this for loop
						alert( "Thanks for your " + item );
					};
				})();
			}
		</script>
	</body>
</html>

원본출처
Anonymous Function에 대한 예제를 구해왔는데요.
scope 문제 때문에 소스가 잘 작동하지 않는거 같기도하고 헷갈려요;;
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:23:30
Processing time 0.0267 sec