Skip to content

Commit 26a8d1f

Browse files
authored
๐Ÿ”€: Udemy/Ts/section5/64: readonly (#40)
* ๐ŸŒฑ: README์„ ์ˆ˜์ • Github์—์„œ ์ˆ˜์ •ํ•œ ์ปค๋ฐ‹์ž…๋‹ˆ๋‹ค. * ๐ŸŒฑ: README์„ ์ˆ˜์ • Github์—์„œ ์ˆ˜์ •ํ•œ ์ปค๋ฐ‹์ž…๋‹ˆ๋‹ค. * ๐ŸŒฑ: README์„ ์ˆ˜์ • Github์—์„œ ์ˆ˜์ •ํ•œ ์ปค๋ฐ‹์ž…๋‹ˆ๋‹ค. * ๐ŸŒฑ: README์„ ์ˆ˜์ • Github์—์„œ ์ˆ˜์ •ํ•œ ์ปค๋ฐ‹์ž…๋‹ˆ๋‹ค. * ๐ŸŒฑ: README์„ ์ˆ˜์ • Github์—์„œ ์ˆ˜์ •ํ•œ ์ปค๋ฐ‹์ž…๋‹ˆ๋‹ค. * ๐ŸŒฑ: README์„ ์ˆ˜์ • Github์—์„œ ์ˆ˜์ •ํ•œ ์ปค๋ฐ‹์ž…๋‹ˆ๋‹ค. * ๐ŸŒฑ: README์„ ์ˆ˜์ • Github์—์„œ ์ˆ˜์ •ํ•œ ์ปค๋ฐ‹์ž…๋‹ˆ๋‹ค. * ๐ŸŒฑ: README์„ ์ˆ˜์ • Github์—์„œ ์ˆ˜์ •ํ•œ ์ปค๋ฐ‹์ž…๋‹ˆ๋‹ค. * ๐ŸŒฑ: README์„ ์ˆ˜์ • Github์—์„œ ์ˆ˜์ •ํ•œ ์ปค๋ฐ‹์ž…๋‹ˆ๋‹ค. * ๐ŸŒฑ: README์„ ์ˆ˜์ • Github์—์„œ ์ˆ˜์ •ํ•œ ์ปค๋ฐ‹์ž…๋‹ˆ๋‹ค. * ๐ŸŒฑ: README์„ ์ˆ˜์ • Github์—์„œ ์ˆ˜์ •ํ•œ ์ปค๋ฐ‹์ž…๋‹ˆ๋‹ค. * ๐ŸŒฑ: README์„ ์ˆ˜์ • Github์—์„œ ์ˆ˜์ •ํ•œ ์ปค๋ฐ‹์ž…๋‹ˆ๋‹ค. * ๐ŸŒฑ: README์„ ์ˆ˜์ • Github์—์„œ ์ˆ˜์ •ํ•œ ์ปค๋ฐ‹์ž…๋‹ˆ๋‹ค. * ๐ŸŒฑ: README์„ ์ˆ˜์ • Github์—์„œ ์ˆ˜์ •ํ•œ ์ปค๋ฐ‹์ž…๋‹ˆ๋‹ค. * ๐ŸŒฑ: README์„ ์ˆ˜์ • Github์—์„œ ์ˆ˜์ •ํ•œ ์ปค๋ฐ‹์ž…๋‹ˆ๋‹ค. * ๐ŸŒฑ: issue templates ์ƒ์„ฑ Github์—์„œ ์ž‘์„ฑํ•œ ์ปค๋ฐ‹์ž…๋‹ˆ๋‹ค. * ๐ŸŒฑ: pr-template ์ƒ์„ฑ Github์—์„œ ์ž‘์„ฑํ•œ ์ปค๋ฐ‹์ž…๋‹ˆ๋‹ค. * ๐ŸŒฑ: pr-template ์ˆ˜์ • Github์—์„œ ์ˆ˜์ •ํ•œ ์ปค๋ฐ‹์ž…๋‹ˆ๋‹ค. * ๐ŸŒฑ: pr-template ์ˆ˜์ • Github์—์„œ ์ˆ˜์ •ํ•œ ์ปค๋ฐ‹์ž…๋‹ˆ๋‹ค. * ๐Ÿšฉ: udemy section2์˜ 14๋ฒˆ ๊ฐ•์˜๋ฅผ ๋“ฃ๊ณ  ์‹ค์Šต์„ ํ–ˆ๋‹ค. * ๐Ÿšฉ: interface๋ฅผ ํ•™์Šตํ•˜๊ธฐ ์œ„ํ•ด ํด๋ž˜์Šค๋ฅผ ํ•™์Šตํ•˜๊ณ  ์‹ค์Šตํ•ด๋ณด์•˜๋‹ค. * ๐Ÿšฉ: dist์˜ ์ปดํŒŒ์ผ๋œ js๋ฅผ ํ™•์ธํ•˜๊ธฐ ์œ„ํ•ด์„œ es5์—์„œ es6๋กœ ts.config ๋ณ€๊ฒฝ * ๐Ÿšฉ: es6์—์„œ es5๋กœ ์ปดํŒŒ์ผ target์„ ๋ณ€๊ฒฝ * ๐Ÿšฉ: this๋ฅผ ์‚ฌ์šฉํ•ด์„œ ์ถœ๋ ฅํ•œ class ๋‚ด ์ „์—ญ name ํ”„๋กœํผํ‹ฐ ์ •์ƒ ์ถœ๋ ฅ * ๐Ÿšฉ: thisํ‚ค์›Œ๋“œ๋ฅผ ๋‹ค์‹œ ํ•œ๋ฒˆ ๊ฐ์ฒด๋กœ ๊ฐ์‹ผ ๋ณต์ œ ํ•จ์ˆ˜ ํ• ๋‹น ํ›„ ์ถœ๋ ฅ undefined ๊ฒฐ๊ณผ ํ™•์ธ, this๋ฅผ ์‚ฌ์šฉ์‹œ ์ฃผ์˜ ์‚ฌํ•ญ * ๐Ÿšฉ: undefined ์žฌํ™•์ธ * ๐Ÿšฉ: ๋ณต์ œํ•œ class์˜ ํ•จ์ˆ˜๋ฅผ ์‚ฌ์šฉ ๊ฐ€๋Šฅํ•˜๊ฒŒ ํ•˜๊ธฐ ์œ„ํ•œ ๋ฐฉ๋ฒ•๊ณผ ์—๋Ÿฌ ์ž„์‹œ์ ์ธ ํ•ด๊ฒฐ ๋‹จ, ๋˜‘๊ฐ™์ด ๊ตฌํ˜„ ๋ถˆ๊ฐ€๋Šฅ * ๐Ÿšฉ: ๋ฐฐ์—ด ํ”„๋กœํผํ‹ฐ์— ์ ‘๊ทผํ•˜๋Š” ๋‘ ๊ฐ€์ง€ ๋ฐฉ์‹ * ๐Ÿšฉ: private ์„ค์ •์œผ๋กœ employees[N]์— ๊ฐ’์„ ํ• ๋‹นํ• ์ˆ˜ ์—†๋‹ค. error * ๐Ÿšฉ: ๋Ÿฐํƒ€์ž„๊ณผ ์ปดํŒŒ์ผ ๊ณผ์ •์˜ private ์˜ํ–ฅ์„ ts, js ํŒŒ์ผ์—์„œ ํ™•์ธ * ๐Ÿšฉ: private๋ฅผ ์ผ๋ฐ˜์ ์œผ๋กœ constructor์—์„œ ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ• * ๐Ÿšฉ: constructor ์ƒ์„ฑ์ž ๋‚ด๋ถ€์— ๋”ฐ๋กœ ์„ ์–ธํ•˜์ง€ ์•Š๊ณ  ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ ์„ ์–ธํ•˜๋Š” ๊ฐ„๋‹จํ•œ ๋ฐฉ๋ฒ• * ๐Ÿšฉ: readonly์˜ ์‚ฌ์šฉ๋ฐฉ๋ฒ•๊ณผ build๋œ app.js์—์„œ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋Š” property ํ‚ค์›Œ๋“œ ํ™•์ธ ๋ฐ ์‹ค์Šต
1 parent 51b7756 commit 26a8d1f

File tree

2 files changed

+3
-31
lines changed

2 files changed

+3
-31
lines changed

โ€Ždist/app.js

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +0,0 @@
1-
"use strict";
2-
var Department = /** @class */ (function () {
3-
function Department(id, name) {
4-
this.id = id;
5-
this.name = name;
6-
// private id: string;
7-
// private name: string;
8-
this.employees = [];
9-
// this.id = id;
10-
// this.name = n
11-
}
12-
Department.prototype.describe = function () {
13-
console.log("Department (".concat(this.id, "): ").concat(this.name));
14-
};
15-
Department.prototype.addEmployee = function (employee) {
16-
this.employees.push(employee);
17-
};
18-
Department.prototype.printEmployeeInformation = function () {
19-
console.log(this.employees.length);
20-
console.log(this.employees);
21-
};
22-
return Department;
23-
}());
24-
var accounting = new Department('1', 'Accounting');
25-
accounting.addEmployee('Max');
26-
accounting.addEmployee('Manu');
27-
// accounting.employees[2] = 'Anna';
28-
accounting.describe();
29-
accounting.printEmployeeInformation();

โ€Žsrc/app.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ class Department {
22
// private id: string;
33
// private name: string;
44
private employees: string[] = [];
5-
6-
constructor(private id: string, public name: string) {
5+
// readonly๋Š” ํ”„๋กœํผํ‹ฐ๋ฅผ ์ดˆ๊ธฐํ™”ํ•œ ํ›„ ์ˆ˜์ •ํ•  ์ˆ˜ ์—†๋‹ค. ์ฆ‰, ํ•œ๋ฒˆ ํ• ๋‹น ๋˜๋ฉด ๋ณ€๊ฒฝ๋˜๋ฉด ์•ˆ๋˜๋Š” ๊ณ ์œ  ๋ฒˆํ˜ธ๋“ค์„ ์„ค์ •ํ•  ๋•Œ readonly๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค.
6+
constructor(private readonly id: string, public name: string) {
77
// this.id = id;
88
// this.name = n
99
}
@@ -12,6 +12,7 @@ class Department {
1212
}
1313

1414
addEmployee(employee: string) {
15+
// this.id = '2'; // readonly์ด๊ธฐ ๋•Œ๋ฌธ์— error๊ฐ€ ๋ฐœ์ƒํ•œ๋‹ค.
1516
this.employees.push(employee);
1617
}
1718
printEmployeeInformation() {

0 commit comments

Comments
ย (0)