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

prototype(์œ ์ „์ž) -๊ฐ์ฒด๋“ค์ด ๊ณตํ†ต์ ์œผ๋กœ ์‚ฌ์šฉํ•˜๋Š” ์†์„ฑ๊ฐ’ ํ”„๋กœํ† ํƒ€์ž…์„ ์‚ฌ์šฉํ•˜์ง€ ์•Š๊ณ , ์ƒ์„ฑ์ž ํ•จ์ˆ˜ ์•ˆ์—์„œ ๋ฉ”์†Œ๋“œ๋ฅผ ์ง์ ‘ ์ •์˜ํ•œ๋‹ค๋ฉด ์–ด๋–ค ๋น„ํšจ์œจ? - ๊ฐ์ฒด๋ฅผ ์ƒ์„ฑํ• ๋•Œ๋งˆ๋‹ค ์ค‘๋ณต์ ์ธ ๋ฉ”์†Œ๋“œ๋กœ ์ธํ•ด, ๋ฉ”๋ชจ๋ฆฌ ๋‚ญ๋น„๊ฐ€ ์ƒ๊น€ ๊ทธ ๋น„ํšจ์œจ์„ ํ”„๋กœํ†  ํƒ€์ž…์„ ํ†ตํ•ด ์–ด๋–ป๊ฒŒ ๊ทน๋ณตํ–ˆ๋Š”์ง€? -๊ฐ์ฒด๋“ค์ด ๊ณตํ†ต์œผ๋กœ ์‚ฌ์šฉํ•˜๋Š” ์†์„ฑ๊ฐ’(ํ”„๋กœํ† ํƒ€์ž…)์„ ์ •์˜ํ•ด์„œ, ๊ฐ์ฒด ์•ˆ์— ์ผ์ผ์ด ๋ฉ”์†Œ๋“œ๋ฅผ ์“ฐ๋Š” ๊ณผ์ •์„ ์ƒ๋žตํ•ด, ํšจ์œจ์ ์ธ ๋ฉ”๋ชจ๋ฆฌ ์‚ฌ์šฉ๊ฐ€๋Šฅ function Person(name,first,second){ this.name =name; this.first=first; this.second=second; } //ํ˜•ํƒœ Person.prototype.sum=function(){ return 'prototype : '+(this.first+this.s..
//๋‚ด์žฅ๊ฐ์ฒด Math console.log("Math.PI", Math.PI); console.log("Math.random()",Math.random());//๊ฐ์ฒด์— ์†Œ์†๋˜์–ด ์žˆ์„๋•Œ๋Š” ๋ฉ”์†Œ๋“œ, ๋ฉ”์†Œ๋“œ๋Š” ๋ณธ์งˆ์ ์œผ๋กœ ํ•จ์ˆ˜ console.log("Math.floor(2.6)",Math.floor(2.6)); //๋‚˜๋งŒ์˜ ๊ฐ์ฒด ๋งŒ๋“ค์–ด๋ณด๊ธฐ //๊ฐ์ฒด๋Š” ๊ทธ๋ฃนํ•‘ํ•ด์„œ ์ด๋ฆ„์„ ๋ถ™์ธ๊ฒƒ์ด๋‹ค let MyMath = { PI:Math.PI, random:function(){ return Math.random(); }, floor:function(val){ return Math.floor(val); } } console.log("MyMath.PI",MyMath.PI); console.log("MyMath.random",MyMath..
๊ฐ์ฒด๋ž€? ์„œ๋กœ ์—ฐ๊ด€๋œ ๋ณ€์ˆ˜์™€ ํ•จ์ˆ˜๋ฅผ ๊ทธ๋ฃนํ•‘ํ•˜๊ณ  ์ด๋ฆ„์„ ๋ถ™์ธ๊ฒƒ! let memberArray = ['์ง€์€','์—ฐ๋ฏธ','๋ฝ€๋ฏธ']; console.log('memberArray[0]',memberArray[0]);// '์ง€์€' let memberObject = { mom:'์—ฐ๋ฏธ', daughter:'์ง€์€', dog:'๋ฝ€๋ฏธ' } memberObject.daughter = '๊ท€์—ฌ์šด ์ง€์œผ๋‹ˆ' //์žฌํ• ๋‹น์„ ํ•ด์คŒ delete memberObject.mom; //mom ์ด๋ผ๋Š” ์†์„ฑ์„ ์‚ญ์ œ console.log('after delete memberObject.mom', memberObject.mom); //undefined console.log("memberObject.daughter",memberObject.daught..
becky(์ง€์€)
'์ƒํ™œ์ฝ”๋”ฉ๊ฐ์ฒด์ง€ํ–ฅํ”„๋กœ๊ทธ๋ž˜๋ฐ' ํƒœ๊ทธ์˜ ๊ธ€ ๋ชฉ๋ก