- JavaScript/2011년스터디/3ì›”ì�´ì „
- JavaScript/2011년스터디/7ì›”ì�´ì „
- JavaScript/2011년스터디/JSON-js분�
- JavaScript/2011년스터디/URLHunter
- JavaScript/2011년스터디/ë°•ì •ê·¼
- JavaScript/2011년스터디/서지혜
- JavaScript/2011년스터디/윤종하
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 ë¬¸ì œ 때문ì—� 소스가 잘 ìž‘ë�™í•˜ì§€ 않는거 같기ë�„í•˜ê³ í—·ê°ˆë ¤ìš”;;
Anonymous Functionì—� 대한 ì˜ˆì œë¥¼ 구해왔는ë�°ìš”.
scope ë¬¸ì œ 때문ì—� 소스가 잘 ìž‘ë�™í•˜ì§€ 않는거 같기ë�„í•˜ê³ í—·ê°ˆë ¤ìš”;;










