๋ณธ๋ฌธ์œผ๋กœ ๋ฐ”๋กœ๊ฐ€๊ธฐ

[์ƒ์„ฑ์ž]
1. ๋ชจ๋“  class๋Š” constructor๋ฅผ ๊ฐ€์ง
2.  constructor๋Š” class๋กœ๋ถ€ํ„ฐ ๊ฐ์ฒด๋ฅผ ์ƒ์„ฑํ•  ๋•Œ ํ˜ธ์ถœ๋˜๋ฉฐ ๊ฐ์ฒด์˜ ์ดˆ๊ธฐํ™”๋ฅผ ๋‹ด๋‹น
ํด๋ž˜์Šค์•ˆ์— ์ปจ์ŠคํŠธ๋Ÿญํ„ฐ๋ฅผ ๋งŒ๋“ค๊ณ 
์˜ค๋ธŒ์ ํŠธ๋ฅผ ์ƒ์„ฑํ•  ๋•Œ๋Š” ํŒŒ๋ผ๋ฉ”ํ„ฐ๋กœ ๋„ฃ๊ธฐ๋งŒ ํ•˜๋ฉด ๋˜๋Š” ์žฅ์ ์ด ์žˆ์Œ ์ด๊ฑฐ ์ž๋ฐ”๋ž‘ ๋˜‘๊ฐ™์€๋ฐ

[access modifiers ์ ‘๊ทผ์ œํ•œ์ž]
ํด๋ผ์Šค ์† ๋ฉค๋ฒ„ ๋ณ€์ˆ˜(ํ”„๋กœํผํ‹ฐ)์™€ 
๋ฉ”์†Œ๋“œ์— ์ ์šฉ๋  ์ˆ˜ ์žˆ๋Š” ํ‚ค์›Œ๋“œ
ํด๋ผ์Šค ์™ธ๋ถ€๋กœ๋ถ€ํ„ฐ์˜ ์ ‘๊ทผ์„ ํ†ต์ œ

public: class์„ ์–ธํ•  ๋•Œ ๋””ํดํŠธ์ž„
private: ํด๋ผ์Šค๋‚ด์—์„œ๋งŒ ์ ‘๊ทผ ๊ฐ€๋Šฅ
protcted: ํด๋ผ์Šค๋‚ด๋ถ€, ์ƒ์†๋ฐ›์€ ์ž์‹ ํด๋ผ์Šค์—์„œ ์ ‘๊ทผ ๊ฐ€๋Šฅ
ํด๋ž˜์Šค๋‚ด ํ”„๋กœํผํ‹ฐ์—์„œ๋„ ์ ‘๊ทผ์ œํ•œ์ž๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Œ

private fullname: string ํ•˜๋ฉด
1) ์™ธ๋ถ€ํด๋ž˜์Šค์—์„œ ์ฝ๊ธฐ/์ˆ˜์ • ๋ถˆ๊ฐ€๋Šฅ
2) ๊ทธ๋Œ€์‹  getter๋ฅผ ์„ ์–ธํ•ด์„œ ๊ทธ ๋ณ€์ˆ˜๋ฅผ ํ”„๋ฆฐํŠธํ•˜๊ธฐ๋กœ ์ฝ๊ธฐ ๊ฐ€๋Šฅ
3) ๊ทธ๋Œ€์‹  setter๋ฅผ ์„ ์–ธํ•ด์„œ ๊ทธ ๋ณ€์ˆ˜๋ฅผ ์ˆ˜์ •ํ•  ์ˆ˜ ์žˆ์Œ

private _fullname: string (๋น„๊ณต๊ฐœ๋ณ€์ˆ˜ ์•”๋ฌต์ ์ปจ๋ฒค์…˜)

constructor์˜ ๋งค๊ฒŒ๋ณ€์ˆ˜์— access modifiers์ง์ ‘ ์ ์šฉ 
๊ฐ์ฒด๊ฐ€ ์ƒ์„ฑ๋  ๋•Œ ์ปจ์ŠคํŠธ๋Ÿญํ„ฐ์˜ ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ ์ „๋‹ฌ๋œ ๊ฐ’์€ ๊ฐ์ฒด์˜ ํ”„๋กœํผํ‹ฐ ๊ฐ’์œผ๋กœ ์ž๋™์œผ๋กœ ๊ฐ’์ด ์ดˆ๊ธฐํ™” ๋˜๊ณ  ํ• ๋‹น

constructor is a method when making a class
ํด๋ž˜์Šค๊ฐ€ ์‹œ์ž‘ํ•  ๋•Œ ๋งˆ๋‹ค ํ˜ธ์ถœ๋œ๋‹ค.

class Human {
	public name: string;
	public age: number;
	public gender: string;

	constructor(name:string, age:number, gender:string){
		this.name = name;
		this.age= age;
		this.gender = gender;
	}
}

const myLove = new Human("myLove", 26 , "Female")




๋ฐ˜์‘ํ˜•