You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: TypeScript/Basics/typescript-basics.md
+41-7Lines changed: 41 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -162,6 +162,7 @@ interface IService {
162
162
## Classes
163
163
164
164
-**Modifiers** <br>
165
+
_Various modifiers allow you to define the scope of variables and methods_
165
166
166
167
```ts
167
168
classExample {
@@ -182,16 +183,14 @@ class Example {
182
183
(not from inherited and outside) */
183
184
private secret ="hello";
184
185
185
-
/* allows access without creating an instance
186
-
of the class may be supplemented by modifiers */
187
-
static sayHello() {
188
-
console.log("Hello!");
189
-
}
186
+
alert = () => {};
190
187
}
191
188
```
192
189
190
+
-**Extending a class** <br>
191
+
_Classes can easily be extended by adding new variables/methods. This also supports overriding methods, but in a way that ensures backward compatibility._
192
+
193
193
```ts
194
-
// Extending a class
195
194
classNewExmapleextendsExample {
196
195
constructor(a:number, b:number, c:number) {
197
196
super(a, b);
@@ -200,8 +199,43 @@ class NewExmaple extends Example {
200
199
201
200
c:number;
202
201
203
-
sayHello(name:string) {
202
+
alert(name?:string) {
204
203
console.log(`Hello ${name}`);
205
204
}
206
205
}
207
206
```
207
+
208
+
-**Abstract classes** <br>
209
+
_Abstract classes/methods do not allow you to create instances, but only serve for expansion_
0 commit comments