Object, Boolean, Function
Object
1
2
3
4
5
6
7
8
const Sohee= {
name: sohee,
gender: female,
age: 123,
job: programmer,
adress:
}
1
console.log(Sohee.job);
programmer
1
2
Sohee.hobby = swimming;
console.log(Sohee.hobby);
swimming
Boolean
- true
- false
- undefined: 존재하지 않는다
- null: 존재는 하나 값이 없다
1
console.log(Sohee.name === sohee);
true
1
console.log(Sohee.adress);
null
1
console.log(Sohee.nationality);
undefined
Function
How to define a Function
Arrow function
1
const add = (a, b) => a + b;
Function expression
1
2
3
const add = function (a, b) {
return a + b;
};
Function & Object
console.log으로 보여주는 함수 만들기
1
2
3
4
5
6
7
8
9
10
11
12
const caculator= {
add: function (a, b) {
console.log("a+b" = a+b);
},
//화살표 함수
minus: (a, b) => {
console.log("a-b" = a-b);
}
}
caculator.add(10+20)
30
return 은 값을 반환
그래서 그 값을 변수에 저장하였음
1
2
3
4
5
6
7
8
9
10
11
12
const caculator = {
add: function (a, b) {
return a + b;
},
//화살표 함수
minus: (a, b) => {
return a - b;
}
};
const result = caculator.add(10 + 20);
console.log(result);
This post is licensed under CC BY 4.0 by the author.