โ ๊ฐ์ฒด
1. ๊ฐ์ฒด๋?
์ฐ๋ฆฌ๊ฐ ์ธ์ํ ์ ์๋ ํ๋์ ์นดํ ๊ณ ๋ฆฌ
ex) ๊ฐ์ฒด - ๋๋ผ
'๋๋ผ'๋ผ๋ '๊ฐ์ฒด'๊ฐ ๊ฐ์ง ์ ์๋ ํน์ง์
์ด๋ฆ, ํฌ๊ธฐ, ์ธ๊ตฌ ์ ๋ฑ์ด ์์
2. ์๋ฐ์คํฌ๋ฆฝํธ์์์ ๊ฐ์ฒด๋?
ํค(key)์ ๊ฐ(value)์ ์์ผ๋ก ์ด๋ค์ง ํ๋กํผํฐ(property)์ ์ ๋ ฌ๋์ง ์์ ์งํฉ
ex) ๊ฐ์ฒด - ๋๋ผ
'๋๋ผ'๊ฐ ๊ฐ์ง ์ ์๋ ํน์ง = 'ํ๋กํผํฐ'
์ด๋ฅผ ํค - ๊ฐ ์์ผ๋ก ๋งคํํ์ฌ ์ ์ฅ
// sample07
const country = {
name: 'Korea',
population: '5178579',
get_name: function(){
return this.name;
}
};
console.log(
country.name,
country.population,
country.get_name()
);
// Korea 5178579 Korea
1) ํ๋กํผํฐ : ๊ฐ์ฒด๊ฐ ๊ฐ์ง ํน์ง, ์ ๋ณด
key | value |
name | Korea |
population | 5178579 |
โก ๊ฐ์ฒด๋ ํ๋กํผํฐ ๋ง๊ณ ๋ ํ์๋ฅผ ๊ฐ์ง ์ ์ด์.
2) ๋ฉ์๋ : ๊ฐ์ฒด ์์ ํจ์
get_name: function(){
return this.name;
}
โ ๋ฐฐ์ด
๋ฐฐ์ด์ด๋?
[์์ 1, ์์ 2,,,] ๋ฅผ ํตํด์ ์์ฑํ์ฌ ์ซ์, ๋ฌธ์์ด, ๊ฐ์ฒด ๋ฑ ๋ค์ํ ๊ฒ๋ค์ ์์๋ก ๋ฃ์ ์ ์์.
1. ๊ตฌ์กฐ ๋ถํด ํ ๋น
: ๊ฐ์ฒด๋ ๋ฐฐ์ด์ ๋ณ์๋ก ๊ฐํธํ๊ฒ '๋ถํด'ํด์ฃผ๋ ๋ฌธ๋ฒ
// sample09
const animal = ['dog', 'cat', 'monkey'];
let [first, second] = animal;
console.log(first); // dog
console.log(second); // cat
2. ๋ฐฐ์ด ๋ด์ฅ ํจ์
1) push() : ๋ฐฐ์ด์ ๋์ ์์ ์ถ๊ฐ
- ๋ฐฐ์ด.push(์์)
- ์์๋ ๊ฐ์ฒด, ์ซ์, ๋ฌธ์์ด ๋ฑ ์ด๋ค ๊ฒ์ด๋ ๊ฐ๋ฅํจ!
// sample 08
const coffee = [];
coffee.push({name: 'Americano'});
coffee.push({name: 'Latte'});
console.log(
coffee, // [ { name: 'Americano' }, { name: 'Latte' } ]
coffee[0],// { name: 'Americano' }
coffee.length // 2
);
2) pop() : ๋ฐฐ์ด์ ๋์ ์์ ์ญ์
- ๋ฐฐ์ด.pop()
const alpha = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
alpha.pop();
console.log(alpha);
// [0, 1, 2, 3, 4, 5, 6, 7, 8 ]
3) forEach() : for๋ฌธ์ ์งง๊ฒ ์ค์
- ํจ์๋ฅผ ์ธ์๋ก ๋ฐ์
- ํจ์์๋ ์ธ ๊ฐ์ ๋งค๊ฐ๋ณ์๊ฐ ์์
[1 - item] ํด๋น ์์ [2 - index] : ์ธ๋ฑ์ค [3 - arr] : ํด๋น ๋ฐฐ์ด (๋ณดํต 3๋ฒ์งธ๋ ์๋ตํจ)
let arr = ["Mike", "Jane", "Tom"];
arr.forEach((name, idx) => {
console.log(name); // Mike Jane Tom
console.log(`${name}'s number is ${idx}`);
});
// ์ถ๋ ฅ๊ฒฐ๊ณผ
/*
Mike's number is 0
Jane's number is 1
Tom's number is 2
*/
4) indexOf() : ์์์ ์ธ๋ฑ์ค ๋ฐํ
- ๋ฐฐ์ด.indexOf(์ซ์) : ์ซ์๊ฐ ๋ฐฐ์ด ์์ ์์ผ๋ฉด ์ธ๋ฑ์ค ๋ฐํ (์์ผ๋ฉด -1 ๋ฐํ)
- ๋ฐฐ์ด.indexOf(a, b) : ์ธ๋ฑ์ค b๋ถํฐ ์ดํด๋ณด์์ ๋, a๊ฐ ์์ผ๋ฉด ์ธ๋ฑ์ค ๋ฐํ (์์ผ๋ฉด -1 ๋ฐํ)
๋ฐฐ์ด.lastIndexOf(์ซ์) : ์ซ์๋ฅผ ๋ค์์๋ถํฐ ์ฐพ๊ธฐ ์์ํจ.
let arr = [1,2,3,4,5,1,2,3];
console.log(
arr.indexOf(3), //2
arr.indexOf(3, 3), // 7
arr.lastIndexOf(2), // 6
arr.indexOf(6) // -1
)
5) find(fn) : ์ฐพ์ ๊ฐ์ ๋ฐํํด์ค
- ํจ์๋ฅผ ์ธ์๋ก ๋ฐ์
- ๋ฐฐ์ด ์์ ์์ผ๋ฉด ์ฒซ๋ฒ์งธ true ๊ฐ๋ง ๋ฐํํจ (์ฌ๋ฌ ๊ฐ ์์ด๋ ์ฒซ๋ฒ์งธ๋ง!)
- ์์ผ๋ฉด undefined ๋ฐํ ๐๐
/* ex 1 */
let arr = [1, 2, 3, 4, 5];
const result = arr.find((item) => {
return item % 3 === 0;
});
console.log(result); // 3
/* ex 2 */
let arr = [1, 2, 3, 4, 5];
const result = arr.find((item) => {
return item % 6 === 0;
});
console.log(result); // undefined
findIndex() : ๋ฐฐ์ด ์์ ์์ผ๋ฉด ์ธ๋ฑ์ค๋ฅผ ๋ฐํ
์์ผ๋ฉด -1 ๋ฐํ
/* ex3 */
let userList = [
{ name: "Mike", age: 30 },
{ name: "Jane", age: 22 },
{ name: "Tom", age: 17 }
];
const teen = userList.find((user) => {
if (user.age < 19) {
return true;
}
return false;
});
const teen2 = userList.findIndex((user) => {
if (user.age < 19) {
return true;
}
return false;
});
console.log(teen); // {name: "Tom", age: 17}
console.log(teen2); // 2
6) filter() : ์กฐ๊ฑด์ ๋ง์กฑํ๋ ๋ฐฐ์ด ์์ฑ
- ํจ์๋ฅผ ์ธ์๋ก ๋ฐ์ ๋ง์กฑํ๋ ๋ชจ๋ ์์๋ฅผ ๋ฐฐ์ด๋ก ๋ฐํํจ.
find()๋ ๋ง์กฑํ๋ ์ฒซ๋ฒ์งธ ์์๋ง!
filter()๋ ๋ง์กฑํ๋ ๋ชจ๋ ์์๋ฅผ!
let arr = [1,2,3,4,5,6,7,8,9,10]
const filter_result = arr.filter((item)=>{
if(!(item%2)) return true;
return false;
});
const find_result = arr.find((item) => {
if(!(item%2)) return true;
return false;
});
console.log(filter_result); // [2, 4, 6, 8, 10]
console.log(find_result); // 2
7) join() : ๋ฐฐ์ด ์์๋ฅผ ๋ฌธ์์ด๋ก ํฉ์นจ
- ๋ฐฐ์ด.join('๋ฌธ์')
- '๋ฌธ์'๊ฐ ์์ผ๋ฉด ',' ๋ฌธ์๋ก ๊ตฌ๋ถ์ง์ด ํฉ์นจ.
- '๋ฌธ์'๊ฐ ์์ผ๋ฉด ๊ทธ ๋ฌธ์๋ก ๊ตฌ๋ถํ์ฌ ํฉ์นจ
let arr = ["๋๋", "์ดํ์ง", "์
๋๋ค."];
console.log(
arr.join(), // ๋๋,์ดํ์ง,์
๋๋ค.
arr.join(" "), // ๋๋ ์ดํ์ง ์
๋๋ค.
arr.join("_") // ๋๋_์ดํ์ง_์
๋๋ค.
);
<-> ๋ฐฐ์ด.split('๋ฌธ์') : '๋ฌธ์'๋ฅผ ๊ธฐ์ค์ผ๋ก ๋๋ ์ค
('๋ฌธ์'๊ฐ ์์ผ๋ฉด ํ๋์ฉ ๋๋ ์ค)
let users = "Mike,Jane,Lucas,Will,Max,Dustin";
const result = users.split(",");
console.log(result); //["Mike", "Jane", "Lucas", "Will", "Max", "Dustin"]
let hello = "hello";
console.log(hello.split("")); // ["h", "e", "l", "l", "o"]
8) map() : ๋ฐฐ์ด ๊ฐ ์์๋ฅผ ๋ฐํ
- ํจ์๋ฅผ ๋ฐ์ ํน์ ๊ธฐ๋ฅ์ ์ํํ๊ณ , ์๋ก์ด ๋ฐฐ์ด์ ๋ฐํํจ
let userList = [
{ name: "Jane", age: 30 },
{ name: "Lee", age: 22 },
{ name: "Eom", age: 26 }
];
let newUser = userList.map((user, idx) => {
return Object.assign({}, user, {
id: idx + 1,
isAdult: user.age > 25
});
});
console.log(userList);
/*
0: {name: 'Jane', age: 30}
1: {name: 'Lee', age: 22}
2: {name: 'Eom', age: 26}
length: 3
*/
console.log(newUser);
/*
0: {name: 'Jane', age: 30, id: 1, isAdult: true}
1: {name: 'Lee', age: 22, id: 2, isAdult: false}
2: {name: 'Eom', age: 26, id: 3, isAdult: true}
length: 3
*/
9) splice() : ์ธ๋ฑ์ค๋ก ํน์ ํญ๋ชฉ ์ ๊ฑฐ
- splice(n, m) : ์ธ๋ฑ์ค n๋ถํฐ m๊ฐ๋ฅผ ์ง์
let arr = [1,2,3,4,5];
arr.splice(1,2);
console.log(arr); // [1,4,5]
- splice(n, m, x) : ์ธ๋ฑ์ค n๋ถํฐ m๊ฐ๋ฅผ ์ง์ฐ๊ณ , x๋ก ์ฑ์
let arr = [1,2,3,4,5];
arr.splice(1,3,200,300);
console.log(arr); // [1, 200, 300, 5]
- splice(n, 0, x) : ์์๋ฅผ ์ง์ฐ์ง ์๊ณ , ์ํ๋ ๊ณณ์ ์์ ์ถ๊ฐ
let arr = ["๋๋", "์ดํ์ง", "์
๋๋ค."];
arr.splice(1, 0, "๋ํ๋ฏผ๊ตญ", "๋ํ์");
console.log(arr); // ['๋๋', '๋ํ๋ฏผ๊ตญ', '๋ํ์', '์ดํ์ง', '์
๋๋ค.']
- ์ญ์ ๋ ์์ ๋ฐํ
let arr = [1, 2, 3, 4, 5];
let result = arr.splice(2, 2);
console.log(
arr, // [1, 2, 5]
result // [3, 4]
);
10) slice() : ํญ๋ชฉ์ ์ ๊ฑฐํ์ฌ ์ ๋ฐฐ์ด ์์ฑ
- slice(n, m) : ์ธ๋ฑ์ค n ~ m-1๊น์ง ๋ฐํ
let arr = [1,2,3,4,5];
console.log(arr.slice(1,4)); // [2, 3, 4]
11) concat : ๋ฐฐ์ด์ ํฉ์ณ์ ์ ๋ฐฐ์ด ์์ฑ
- concat(arr1, arr2,,,,)
let arr1 = [1, 2, 3];
let arr2 = arr1.concat([4]);
let arr3 = arr2.concat([5, 6], [7, 8]);
console.log(
arr1, //[1, 2, 3]
arr2, //[1, 2, 3, 4]
arr3 //[1, 2, 3, 4, 5, 6, 7, 8]
);
12) reduce() : ๋์ ๊ฐ ๊ณ์ฐ
- reduce(ํจ์, ์ด๊ธฐ ๊ฐ)
prev : ๋์ ๊ณ์ฐ ๊ฐ / cur : ํ์ฌ ๊ฐ / return ๊ณ์ฐ ๊ฐ
let userList = [
{ name: "Mike", age: 10 },
{ name: "Lucas", age: 9 },
{ name: "Jane", age: 11 },
{ name: "Will", age: 8 },
{ name: "Dustin", age: 12 },
{ name: "Max", age: 13 }
];
let result = userList.reduce((prev, cur) => {
if (cur.age > 10) {
prev.push(cur.name);
}
return prev;
}, []);
console.log(result); // ["Jane", "Dustin", "Max"]
ex) ํฉ๊ณ ๊ตฌํ๊ธฐ (reduce ๋ฏธ์ฌ์ฉ)
/* ํฉ๊ณ ๊ตฌํ๊ธฐ */
// ๋ฐฉ๋ฒ 1 - for ๋ฐ๋ณต๋ฌธ
let result = 0;
for(let i = 0; i<arr.length; i++){
result += arr[i];
}
console.log(result); // 15
// ๋ฐฉ๋ฒ 2 - for..in ๋ฐ๋ณต๋ฌธ
let result = 0;
for(let i in arr){
result += arr[i];
}
console.log(result); // 15
// ๋ฐฉ๋ฒ 3 - for of
let result = 0;
for(let i of arr){
result += i;
}
console.log(result); // 15
// ๋ฐฉ๋ฒ 4 - forEach()
let result = 0;
arr.forEach((i) => {
result += i;
})
console.log(result); // 15
ex) reduce๋ฅผ ์ฌ์ฉํ์ฌ ํฉ๊ณ ๊ตฌํ๊ธฐ
// ex 1
let arr = [1,2,3,4,5];
const sum = arr.reduce((prev, cur) => {
return prev + cur;
}, 0);
console.log(sum); // 15
13) includes() : ํฌํจํ๋์ง ํ์ธ
- ํฌํจํ๋ฉด true ๋ฐํ
- ํฌํจํ์ง ์์ผ๋ฉด false ๋ฐํ
let arr = [1,2,3];
console.log(
arr.includes(2), // true
arr.includes(8), // false
);
14) Array.isArray() : ๋ฐฐ์ด๊ณผ ๊ฐ์ฒด ๊ตฌ๋ถ
๐ ์ฃผ์!
typeof()๋ก ๋ฐฐ์ด๊ณผ ๊ฐ์ฒด๋ฅผ ํ๋ณํ๋ฉด ๋ ๋ค ๋ฐฐ์ด์ด ๋์ด
- Array.isArray(๋ฐฐ์ด)๋ฅผ ์ฌ์ฉํ๋ฉด ๋์ ๊ตฌ๋ถ์ด ๊ฐ๋ฅํจ
let user = {
name: "Lee",
age: 22
};
let users = ["Lee", "Kim", "Woo"];
console.log(
typeof user, // object
typeof users, // object
Array.isArray(user), // false
Array.isArray(users) // true
);
15) sort() : ๋ฐฐ์ด ์ฌ์ ๋ ฌ
- ์ ๋ฐฐ์ด์ ๋ฐํํ๋ ๊ฒ์ด ์๋๋ผ, ๋ฐฐ์ด ์์ฒด๊ฐ ๋ณ๊ฒฝ๋๋ ์ฃผ์ํด์ผํจ! ๐ฅ๐ฅ๐ฅ
- ์ธ์๋ก ์ ๋ ฌ ๋ก์ง์ ๋ด์ ํจ์๋ฅผ ๋ฐ์
let arr = [1,5,2,4,3];
let arr2 = [13, 21, 5, 44]
console.log(
arr.sort(), // [1, 2, 3, 4, 5]
arr2.sort(), // [13, 21, 44, 5]
);
๐ ์ฃผ์!
sort()๋ ๋ฐฐ์ด์ ์์๋ฅผ ๋ฌธ์๋ก ์๊ฐํ๊ณ ์ ๋ ฌํ๊ธฐ ๋๋ฌธ์
13๊ณผ 5๋ฅผ ๋น๊ตํ ๋ '1' vs '5'๋ฅผ ๋น๊ตํ์ฌ 13์ด ์ ์์๋ก ๋์ค๊ฒ ๋จ.
โก ํด๊ฒฐ์ฑ
let arr2 = [13, 21, 5, 44];
console.log(
arr2.sort((a,b)=>{
return a-b;
}) // [5, 13, 21, 44]
);
16) reverse() : ์ญ์ ์ฌ์ ๋ ฌ
- ๊ฐ์ฅ ์ต๊ทผ์ ๋๊ธ์ ์์ฑํ ์ฌ๋, ๋ฐฉ๋ฌธํ ์ฌ๋ ๋ฑ์ ์ฐพ์ ๋ ์ฌ์ฉ
let arr = [1,2,3,4,5];
arr.reverse();
console.log(arr); // [5, 4, 3, 2, 1]
โ ํจ์
1. ํจ์ ์ ์ธ
1) function์ ํตํด ์ ์ธ
2) () ์์ ํ๋ผ๋ฏธํฐ ์ง์
3) {}๋ฌธ ์์ ๋ก์ง ์์ฑ
4) return์ ํตํด ๋ฐํ ๊ฐ ์ ์ฅ
// sample10
function add(a, b){
return a+b;
}
console.log(add(1,4)); // 5
2. ํ์ดํ ํจ์
(ES6๋ถํฐ ๋์ ๋ ํ์ดํ(Arrow) ํจ์, ๋๋ค์)
function ๋์ => ๋ฅผ ํตํด ์ ์ธ ๊ฐ๋ฅ
const add = (a, b) =>{
return a + b;
}
console.log(add(1,2)); // 3
๋ง์ฝ ํจ์ ์์ return ๋ฐ์ ์๋ค๋ฉด?
const add = (a,b) => a+b;
{ }์ return ์๋ต ๊ฐ๋ฅ
3. ํ์ดํ ํจ์์ ํน์ง
: ํจ์๋ช
/ arguments / this ๊ฐ ์์
[ํจ์๋ช ]
ํจ์๋ช ์ด ์์ โก ์ต๋ช ํจ์๋ก ๋์ํ๋ค๋ ๋ป
[arguments]
1) ๋ณดํต ํจ์๊ฐ ์์ฑ๋๋ฉด?
์์ ์ ์ค์ฝํ ์์ ์๊ธฐ ์์ ์ ๊ฐ๋ฆฌํค๋ this์ ํ๋ผ๋ฏธํฐ๊ฐ ๋ด๊ธฐ๋ arguments๊ฐ ์๋์ผ๋ก ์์ฑ๋จ
const func = function(){
console.log(arguments)
};
func(1,2,3,4); // Arguments(4) [1, 2, 3, 4]
* ํ๋ผ๋ฏธํฐ : ๋งค๊ฐ๋ณ์
2) ํ์ดํ ํจ์์ ๊ฒฝ์ฐ๋?
- ์๋์ผ๋ก arguments๊ฐ ์์ฑ๋์ง ์์
const func = () =>{console.log(args)};
func(1,2,3);
// ERROR ๋ฐ์
/*
VM381:1 Uncaught ReferenceError: args is not defined
at func (<anonymous>:1:32)
at <anonymous>:1:1
*/
- ํ์ํ๋ค๋ฉด ํจ์์ ํ๋ผ๋ฏธํฐ ๋ถ๋ถ์ ...args๋ฅผ ๋ฃ์ด args๋ผ๋ ๋ฐฐ์ด ์์ ํ๋ผ๋ฏธํฐ๋ฅผ ๋ด์ ์ ์์.
const func = (...args) =>{console.log(args)};
func(1,2,3); // [1, 2, 3]
๐ก ์ฐธ๊ณ ์ฌํญ ๐ก
... : ์ ๊ฐ ์ฐ์ฐ์
๊ฐ์ด ๋ช ๊ฐ๊ฐ ๋ ์ง ๋ชจ๋ฅด๋ ๋ค์ ์ค๋ ๋ณ์๋ช ์ ๊ฐ์ ๋ฐฐ์ด๋ก ๋ฃ์ ์ ์์.
[this]
1) console.log(this); ๋ฅผ ์ฐ์ด๋ณด๋ฉด ๊ฒฐ๊ณผ๋ก Window ๊ฐ์ฒด๊ฐ ๋์ด.
console.log(this);
// Window {0: Window, window: Window, self: Window, document: document, name: '', location: Location, …}
์ด์ ๋?
console.log(this)๋ฅผ ํธ์ถํ ํจ์๋ ์ ์ญ์ด๊ณ ๋ธ๋ผ์ฐ์ ์์ Global์ Window ๊ฐ์ฒด๋ฅผ ์๋ฏธํ๊ธฐ ๋๋ฌธ!
2) this์ ์ฌ์ฉ
// sample12
var people = {
name: 'gildong',
say(){
console.log(this);
}
};
people.say();
var sayPeople = people.say;
sayPeople();
// ์ถ๋ ฅ๊ฒฐ๊ณผ
/*
{ name: 'gildong', say: [Function: say] }
<ref *1> Object [global] {
global: [Circular *1],
clearInterval: [Function: clearInterval],
clearTimeout: [Function: clearTimeout],
setInterval: [Function: setInterval],
setTimeout: [Function: setTimeout] {
[Symbol(nodejs.util.promisify.custom)]: [Getter]
},
queueMicrotask: [Function: queueMicrotask],
performance: Performance {
nodeTiming: PerformanceNodeTiming {
name: 'node',
entryType: 'node',
startTime: 0,
duration: 32.825800001621246,
nodeStart: 0.4677000045776367,
v8Start: 2.4589000046253204,
bootstrapComplete: 22.77639999985695,
environment: 11.898200005292892,
loopStart: -1,
loopExit: -1,
idleTime: 0
},
timeOrigin: 1660719347749.774
},
clearImmediate: [Function: clearImmediate],
setImmediate: [Function: setImmediate] {
[Symbol(nodejs.util.promisify.custom)]: [Getter]
}
}
- people.say() ์์๋ people ๊ฐ์ฒด๊ฐ say()๋ฅผ ํธ์ถํจ โก this๋ people ๊ฐ์ฒด
- sayPeople ๋ณ์์ people.say๋ฅผ ๋ฃ๊ณ ํธ์ถํจ โก ์ ์ญ๋ณ์๊ฐ ํธ์ถํ ์ฃผ์ฒด๊ฐ ๋๋ฏ๋ก this๋ ์ ์ญ ๊ฐ์ฒด
3) this ๊ฐ์ฒด๋ฅผ ๊ณ ์ ํ๊ณ ์ถ๋ค๋ฉด?
bind(this๋ก ๊ณ ์ ์ํฌ ๊ฐ์ฒด) ํจ์ ์ด์ฉ
let people = {
name: 'gildong',
say(){
console.log(this);
}
};
people.say();
let sayPeople = people.say.bind(people);
sayPeople();
// ์ถ๋ ฅ๊ฒฐ๊ณผ
/*
{ name: 'gildong', say: [Function: say] }
{ name: 'gildong', say: [Function: say] }
*/
โก ๊ทธ๋ฌ๋ ํ์ดํ ํจ์๋ก ๋ง๋ค์ด์ง ๊ฐ์ฒด ๊ฒฝ์ฐ this๊ฐ ์กด์ฌํ์ง ์๊ธฐ ๋๋ฌธ์ bind๋ฅผ ์ฌ์ฉํด๋ this๋ฅผ ์ฃผ์ ํ ์ ์์.
4) this๊ฐ ์๋ค๋ ๊ฒ์ ์๋ฏธ๋?
ํ์ดํ ํจ์๋ก ๋ง๋ค์ด์ง ๊ฐ์ฒด์ this๋ฅผ ์ฌ์ฉํ๋ฉด,
์ผ๋ฐ์ ์ธ ์ธ์๋ ๋ณ์์ ๋์ผํ๊ฒ ์ทจ๊ธํ๊ธฐ ๋๋ฌธ์
๋ด๋ถ ์ค์ฝํ์ this๊ฐ ์๊ณ ์์ ํจ์์ this๋ ์ ์ญ๊ฐ์ฒด์ this๋ฅผ ๋ถ๋ฌ์ค๊ฒ ๋จ.
๐ฅ ๊ฐ๋จํ๊ฒ ์ ๋ฆฌํ์๋ฉด?
๊ฐ์ฒด ์ ๋ฉ์๋์ this = ๊ทธ ๋ฉ์๋๊ฐ ๋ด๊ธด ๊ฐ์ฒด
ํจ์ ์์ this = ์ ์ญ ๊ฐ์ฒด