๊ฐ์ฒด์ƒ์†

Object.create() __proto__ ๋Œ€์‹ ์— 'Object.create()' ๋ฅผ ์‚ฌ์šฉํ•ด์„œ prototype link(๋ช…ํ™•ํ•œ ์ƒ์†๊ด€๊ณ„)๋ฅผ ์ง€์ •ํ•ด์ค„ ์ˆ˜ ์žˆ๋‹ค. let lee = Object.create(kim); kim์„ ๋ถ€๋ชจ๋กœ ํ•˜๋Š” ์ž์‹๊ฐ์ฒด lee๋ฅผ ๋งŒ๋“ค์–ด์ค˜ let superObj = {superVal:'super'} //let subObj = {subVal:'sub'} //subObj.__proto__ = superObj; let subObj = Object.create(superObj);// superObj๋ฅผ ๋ถ€๋ชจ๋กœ ํ•˜๋Š” ์ƒˆ๋กœ์šด ๊ฐ์ฒด,๋ณด๋‹ค prototype link(๋ช…ํ™•ํ•œ ์ƒ์†๊ด€๊ณ„)๋ฅผ ํ™•๋ฆฝ! subObj.subVal = 'sub'; //์ฃผ์„์ฒ˜๋ฆฌ๋ฅผ ํ•œ ์œ„์˜ ์ฝ”๋“œ์™€ ๋˜‘๊ฐ™์ด ๋™์ž‘ console.lo..
'__proto__' lee.__proto__ = kim; lee๋Š” kim์˜ ์ž์‹์ด๋‹ค // class ๋ฌธ๋ฒ•์ด ์•„๋‹ˆ๋ผ ์•„์ฃผ ๊ด€์Šต์ (prototype)์œผ๋กœ ์ƒ์†ํ•˜๋Š” ๋ฐฉ๋ฒ• let superObj = {superVal:'super'} let subObj = {subVal:'sub'} // ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ์˜ ๊ต‰์žฅํžˆ ์œ ์—ฐํ•œ ํŠน์ง•! // ๋งˆ์Œ๋Œ€๋กœ ๋ˆ„๊ตฐ๊ฐ€์˜ ์ž์‹์ด ๋  ์ˆ˜ ์žˆ๋‹ค subObj.__proto__ = superObj; // '__proto__'๋ผ๋Š” ๋งํฌ๋ฅผ ๊ฑธ์–ด์คŒ: subObj๋Š” ์„ ์กฐ๋Š” superObj์ด๋‹ค console.log('subObj.subVal =>',subObj.subVal); console.log('subObj.superVal =>',subObj.superVal);// ๊ฐ์ฒด subObj๊ฐ€ superVa..
becky(์ง€์€)
'๊ฐ์ฒด์ƒ์†' ํƒœ๊ทธ์˜ ๊ธ€ ๋ชฉ๋ก