์ „์ฒด ๊ธ€

๐Ÿ‘ฉ‍๐Ÿ’ป java, mysql, android, php, javascript๋ฅผ ๋‹ค๋ฃน๋‹ˆ๋‹ค
super ํ‚ค์›Œ๋“œ super() ํ‚ค์›Œ๋“œ๋Š” ์ƒ์œ„(๋ถ€๋ชจ)๊ฐ์ฒด์˜ ํ•จ์ˆ˜๋ฅผ ํ˜ธ์ถœํ•  ๋•Œ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค ๋‹จ, constructor(์ƒ์„ฑ์ž) ์•ˆ์—์„œ๋Š” super ํ‚ค์›Œ๋“œ ํ•˜๋‚˜๋งŒ ์‚ฌ์šฉ๋˜๊ฑฐ๋‚˜ this ํ‚ค์›Œ๋“œ ์ „์— ๋จผ์ € ํ˜ธ์ถœ๋˜์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค ๋ถ€๋ชจ ํด๋ž˜์Šค์˜ ์˜์—ญ์„, ์ž์‹ํด๋ž˜์Šค(๋‚˜)๋„ ํฌํ•จํ•˜๊ณ  ์žˆ๋Š” ๊ฒฝ์šฐ! ์ค‘๋ณต์„ ์ค„์ด๋ ค๊ณ  ๊ทธ๋•Œ, ์‚ฌ์šฉํ•˜๋Š” ํ‚ค์›Œ๋“œ 'super' super ํ˜•ํƒœ 2๊ฐ€์ง€ 1.super() = ๋ถ€๋ชจ ํด๋ž˜์Šค์˜ ์ƒ์„ฑ์ž(constructor) 2.super. = ๋ถ€๋ชจํด๋ž˜์Šค์˜ class Person { constructor(name, first, second){ this.name =name; this.first=first; this.second=second; } sum(){ return this.first+this.second; } ..
Class inheritance ์ƒ์†์„ ์“ฐ๋Š” ์ด์œ : ์ค‘๋ณต์ฝ”๋“œ๋ฅผ ์ œ๊ฑฐํ•˜๊ธฐ ์œ„ํ•จ. ์ฆ‰, ๋ถ€๋ชจํด๋ž˜์Šค๋ฅผ ์ผ์ผ์ด ์“ฐ์ง€์•Š๊ณ , ๋ฐ๋ ค์™€ ์ƒˆ๋กœ์šด ๊ธฐ๋Šฅ์„ ์ž์‹ class์— ์ถ”๊ฐ€ํ•ด ์ฃผ๊ณ  ์‹ถ์„๋•Œ ํ˜•ํƒœ : ์ž์‹ํด๋ž˜์Šค์ธ PersonPlus ๋Š” ๋ถ€๋ชจํด๋ž˜์Šค์ธ Person์˜ ์†์„ฑ์„ ๊ฐ€์ง€๊ณ  ์™€์„œ ๊ณต์œ ํ•œ๋‹ค ๋”ฐ๋ผ์„œ, ๋ถ€๋ชจํด๋ž˜์Šค Person์˜ ์†์„ฑ์„ ์ˆ˜์ •ํ•œ๋‹ค๋ฉด, ์ž์‹ํด๋ž˜์Šค PersonPlus ์†์„ฑ๋„ ์ˆ˜์ •๋จ //๋ถ€๋ชจํด๋ž˜์Šค class Person { constructor(name, first, second){ this.name =name; this.first=first; this.second=second; } sum=()=>{ return (this.first+this.second); } } //์ž์‹ํด๋ž˜์Šค class PersonPlus exte..
๋ฐฐํฌ๋งํฌ: https://jieun9999.github.io/fe-sprint-my-agora-states/ My Agora States kimploo / 2022.4.22 ์˜คํ›„ 2:08:33 jieun9999.github.io ๋‚˜๋งŒ์˜ ์•„๊ณ ๋ผ ์Šคํ…Œ์ด์ธ ๋ฅผ ๋งŒ๋“ค์–ด๋ณด์•˜๋‹ค. ์ž๋ž‘์Šค๋Ÿฝ๊ฒŒ ๋ฒ ์–ด๋ฏธ๋‹ˆ๋ฉˆ์„ ์™„์ˆ˜ํ–ˆ๋‹ค. ๋ฐฐํฌ๋งํฌ๋„ ๋งŒ๋“ค๊ณ , pull request ๋„ ์™„๋ฃŒํ•ด๋ณด์•˜๋‹ค. ํŠนํžˆ, ์œ„์— ์ž…๋ ฅ์ฐฝ์— ์ •๋ณด๋ฅผ ์ž…๋ ฅํ•˜๋ฉด, ์•„๋ž˜์— ๋ฐ์ดํ„ฐ๊ฐ€ ๊ฐ€์‹œ์ ์œผ๋กœ ๋ˆ„์ ๋˜๋Š” ๊ฒƒ์ด ์‹ ๊ธฐํ•ด๋”ฐ.. ํ—คํ—ค ๋ฐฐ์šด์  = '๋ฉ”ํƒ€์ธ์ง€' ๊ธฐ๋ฅด๊ธฐ ๋‚ด๊ฐ€ ๋ญ˜ ์•Œ๊ณ , ๋ญ˜ ๋ชจ๋ฅด๋Š”์ง€ ํŒŒ์•…ํ•˜๊ธฐ ๋‚ด๊ฐ€ ์ฒ˜์Œ์— ๋น ๋œจ๋ฆฐ ๋ถ€๋ถ„์€ ์ฒซ๋ฒˆ์งธ ๋ฐฐ์—ด์— ํ•ด๋‹นํ•˜๋Š” ์ •๋ณด๋ฅผ ๋‹ค ๋ฐ›์•„๋†“๊ธฐ๋งŒ ํ–ˆ๋‹ค๋Š” ๊ฒƒ์ด๋‹ค. 40๊ฐœ์˜ ๋ฐฐ์—ด์€ out of ์•ˆ์ค‘ ๋ฐ˜๋ณต๋ฌธ์„ ๊ณ ๋ คํ•˜์—ฌ, ์ฝ˜์†”์„ ๋ณด๋ฉด์„œ ๋ฌธ์ œ๋ฅผ ์ฐพ์•„์•ผ ํ–ˆ์Œ >>๋™์‹œ..
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()..
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..
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
//๋‚ด์žฅ๊ฐ์ฒด 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..
becky(์ง€์€)
Know yourself, follow your passion