-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjs06_function.html
More file actions
52 lines (44 loc) · 1.27 KB
/
js06_function.html
File metadata and controls
52 lines (44 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h3>다양한 함수 문법</h3>
<script>
function f1(){
console.log("f1()");
}
f1();
f1(2);
console.log("---2---");
//익명함수, 함수 표현식을 하나의 변수에 대입
let sum = function(x, y){
return x+y;
}
let data = sum(1, 2);
console.log(data);
//즉시 실행 함수 - 구현 & 호출
console.log("---3---");
(function f2(){
console.log("f2()");
}());
(function f3(v){
console.log("f3()" + v);
}("data"));
//익명함수를 콜백(등록.. 떄가되면 실행)함수로 등록해서 서용
//window 객체 내부에 setTimeout()
//body에 단순 출력하는 기능의 함수
//? 3초 후에 print() 함수 호출
// setTimeout(print,3000);
// function print(){
// document.write("단순 출력 <br>");
// }
setTimeout(function(){
document.write("단순 출력 <br>");
},3000);
</script>
</body>
</html>