์ƒํ™œ์ฝ”๋”ฉ ๊ฐ์ฒด์ง€ํ–ฅํ”„๋กœ๊ทธ๋ž˜๋ฐ

Class๋Š” ๋ญ๋‹ค? constructor ๋ฉ”์†Œ๋“œ๋ฅผ ์‚ฌ์šฉํ•ด ๋ณด๋‹ค ์‰ฝ๊ฒŒ ๊ฐ์ฒด๋ฅผ ๋งŒ๋“œ๋Š” ๊ณต์žฅ! prototype ๊ธฐ๋ฐ˜์˜ ๊ฐ์ฒด๋ฅผ ๋งŒ๋“œ๋Š” ๊ณต์žฅ์ด ์žˆ๊ณ , (๋ณด๊ธฐ์‰ฌ์›€) class ๊ธฐ๋ฐ˜์˜ ๊ฐ์ฒด๋ฅผ ๋งŒ๋“œ๋Š” ๊ณต์žฅ์ด ์žˆ๋‹ค. // ์ƒ์„ฑ๋œ ๊ฐ์ฒด๋ฅผ ์–ด๋–ป๊ฒŒ ์ดˆ๊ธฐํ™”? // ๋จผ์ € ์‹คํ–‰๋˜๋„๋ก ๋งŒ๋“ค์–ด์ง„ constructor ํ•จ์ˆ˜๋ฅผ class ๋‚ด์—์„œ ๊ตฌํ˜„ class Person { constructor(name, first, second){ this.name =name; this.first=first; this.second=second; } sum=()=>{ return 'class : '+(this.first+this.second); } } let kim = new Person('kim',10,20); kim.sum = function()..
Constructor function(์ƒ์„ฑ์ž ํ•จ์ˆ˜) ๊ฐ์ฒด ์–‘์‚ฐ ํ•จ์ˆ˜, ์ฆ‰ ๊ฐ์ฒด๋ฅผ ์ฐ์–ด๋‚ด๋Š” ํ•จ์ˆ˜์ด๋‹ค. ์ด์ „์—๋Š” ํ•˜๋‚˜์˜ ๊ฐ์ฒด๋งˆ๋‹ค ํ‚ค์™€ ๊ฐ’์„ ๋ถ€์—ฌํ•ด์คฌ๋‹ค๋ฉด, ์ปจ์ŠคํŠธ๋Ÿญํ„ฐ์™€ new ๋ผ๋Š” ๊ฐ์ฒด์ƒ์„ฑ ํ‚ค์›Œ๋“œ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์ปจ์ŠคํŠธ๋Ÿญํ„ฐ์— ์ •์˜๋˜์–ด ์žˆ๋Š” ์†์„ฑ๊ณผ ๋ฉ”์†Œ๋“œ๋ฅผ ํ•œ๋ฒˆ์— ๋ฐ›์•„์˜ฌ ์ˆ˜ ์žˆ๊ณ , ๊ฐ๊ฐ์˜ ๊ฐ’์€ ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ ๋ฐ›์•„ ๊ฐ ์ƒํ™ฉ๋งˆ๋‹ค ๋ณ€๊ฒฝํ•˜์—ฌ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค. // ํ•จ์ˆ˜์— ๋งค๊ฐœ๋ณ€์ˆ˜๋ฅผ ๋งŒ๋“ค์–ด์ค€๋‹ค function Person(name,first,second,third){ this.name =name; this.first=first; this.second=second; this.third=third; this.sum=function(){ return this.first+this.second+this.third; } } // ์ƒ์„ฑ์žํ•จ์ˆ˜..
this = '๋‚˜'! this๋Š” this๊ฐ€ ์†ํ•ด์žˆ๋Š” ๋ฉ”์†Œ๋“œ๊ฐ€ ์†ํ•ด์žˆ๋Š” ๊ฐ์ฒด๋ฅผ ๊ฐ€๋ฆฌํ‚ด! ๊ฐ์ฒด์˜ ์ด๋ฆ„์ด ๋ฐ”๋€Œ์–ด๋„ ์›๋ž˜์˜ ๋กœ์ง์„ ์œ ์ง€ํ•  ์ˆ˜ ์žˆ์–ด์„œ ์žฌ์‚ฌ์šฉ์— ๋„์›€์ด ๋จ. let kim = { name:'kim', first:10, second:20, sum:function(){ return this.first+this.second; } } console.log("kim.sum()",kim.sum()); //kim.sum() 30
let memberArray = ['์ง€์€','์—ฐ๋ฏธ','๋ฝ€๋ฏธ']; console.group('array loop'); let i =0; while(i
becky(์ง€์€)
'์ƒํ™œ์ฝ”๋”ฉ ๊ฐ์ฒด์ง€ํ–ฅํ”„๋กœ๊ทธ๋ž˜๋ฐ' ํƒœ๊ทธ์˜ ๊ธ€ ๋ชฉ๋ก