-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path3-05(ArrowFunction).html
More file actions
51 lines (41 loc) · 1.39 KB
/
3-05(ArrowFunction).html
File metadata and controls
51 lines (41 loc) · 1.39 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
<html>
<head>
<title>Arrow Function</title>
</head>
<body>
<script>
// hello1(); // error 발생 X, why? 함수 선언
// function hello1() {
// console.log("Hello World");
// return "Welcome";
// }
// hello1(); // 일반적 호출 방식
// hello2(); // error 발생, why? 변수 선언
// var hello2 = function(){
// console.log("Hello World");
// return "Welcome";
// }
// hello2();
// arrow function
// var hello3 = () => {
// console.log("Hello World");
// return "Welcome";
// }
// hello3();
// var hello4 = () => "Welcome";
// console.log(hello4()); // Welcome
// function hello5(fullName) {
// return "Welcome" + " " + fullName;
// }
// console.log(hello5("홍길동"));
// hello5를 arrow function으로 변환
// var hello5 = (fullName) => "Welcome" + " " + fullName;
// console.log(hello5("홍길동"));
// var hello5 = (firstName, lastName) => "Welcome" + " " + firstName + " " + lastName;
// console.log(hello5("홍", "길동"));
// 매개변수가 하나일 경우에는 () 생략 가능
var hello5 = fullName => "Welcome" + " " + fullName;
console.log(hello5("홍길동"));
</script>
</body>
</html>