<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script>
console.log(typeof(function(){}));
let a = function(x, y){
return x+y;
};
console.log(a);
let result = a(1, 3);
console.log('result : ', result);
(function(){console.log('test')})();
(function(x, y) {console.log(x+y);})('goodee', 'hello');
let b = a;
let result2 = b(7,10);
console.log('result2 : '+result2);
console.log(typeof(b));
b.nicname = '구디아카데미 함수';
console.log('b.name :' ,b.nicname );
b.play = function(){ console.log('놀다')};
b.play();
let arr = [
function(){console.log('첫번째 배열 함수')},
function(){console.log('두번째 배열 함수')},
function(){console.log('세번째 배열 함수')}
];
arr.forEach(function(item, idx){
console.log(idx);
item();
}
)
let c = function(){
let d ='ccc'
console.log('ccc')
let e = function(){
console.log('eee');
};
return e;
};
let f = c();
f();
c()();
let g = function(fun){
fun();
};
let odd = function(){
alert('짝수 입니다');
};
let even = function(){
alert('홀수 입니다');
};
let param = null;
let num = 7;
if(num % 2 == 0){
param = even;
} else {
param = odd;
}
g(param);
</script>
</head>
<body>
</body>
</html>