Skip to content

Commit 6e48c32

Browse files
authored
Update classes.md
1 parent 5505557 commit 6e48c32

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

docs/classes.md

+12-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ var Point = (function () {
3535
return Point;
3636
})();
3737
```
38-
This is a fairly idiomatic traditional JavaScript class pattern now as a first class language construct. Note that `constructor` is optional.
38+
This is a fairly idiomatic traditional JavaScript class pattern now as a first class language construct.
3939

4040
### Inheritance
4141
Classes in TypeScript (like other languages) support *single* inheritance using the `extends` keyword as shown below:
@@ -118,6 +118,15 @@ As always these modifiers work for both member properties and member functions.
118118
* `abstract` **classes** cannot be directly instantiated. Instead the user must create some `class` that inherit from the `abstract class`.
119119
* `abstract` **members** cannot be directly accessed and a child class must provide the functionality.
120120

121+
### Constructor is optional
122+
123+
The class does not need to have a constructor. e.g. the following is perfectly fine.
124+
125+
```ts
126+
class Foo {}
127+
let foo = new Foo();
128+
```
129+
121130
### Define using constructor
122131

123132
Having a member in a class and initializing it like below:
@@ -150,3 +159,5 @@ class Foo {
150159
}
151160
}
152161
```
162+
163+

0 commit comments

Comments
 (0)