Skip to content

Commit 59826de

Browse files
Lensco825sumn2u
andauthored
Added description on class chapter and inheritance (sumn2u#192)
* Began writing set-interval document * Added code example for setInterval * Completed example on setInterval paramters * Added clear interval section * Revised set-interval document * Created set-timeout document * Added clear timeout secion * Added info on Inheritance document and class chapter * Added chapter and page number to setTimeout and SetInterval --------- Co-authored-by: Suman Kunwar <suman.kunwar@daliaresearch.com>
1 parent 8453120 commit 59826de

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

en/classes/README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ description: Classes are templates for creating an object. It encapsulates data
88
# Chapter 15
99
# Classes
1010

11-
Classes are templates for creating an object. It encapsulates data with code to work on with data. The keyword `class` is used to create a class. And a specific method called `constructor` is used for creating and initializing an object created with a `class`. An example of car class is shown below.
11+
Classes are templates for creating an object. It encapsulates data with code to work on with data. For example if we want to make a family tree of birds, we can make a bird class and every bird object we make will have the methods and data from the bird class.
12+
13+
The keyword `class` is used to create a class. And a specific method called `constructor` is used for creating and initializing an object created with a `class`. An example of car class is shown below.
1214

1315
```javascript
1416
class Car {
@@ -31,3 +33,5 @@ Class must be defined before its usage.
3133
{% endhint %}
3234

3335
In the class body, methods or constructors are defined and executed in `strict mode`. Syntax not adhering to the strict mode results in error.&#x20;
36+
37+
Every time we create an object from a class we’re creating an **instance** of that class, for example the `myCar` variable above us with the `new` keyword is an instance. Instances are *independant* meaning it doesn’t affect any other instance. This is why classes are thought to be templates for objects. Since once you make that instance object it'll have the same methods as the original class.

en/classes/inheritance.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,9 @@ console.log(myCar.show()); // I have a Camry, it is a Toyota.
3535
The prototype of the parent class must be an `Object` or `null`.&#x20;
3636
{% endhint %}
3737

38-
The `super` method is used inside a constructor and refers to the parent class. With this, one can access the parent class properties and methods.
38+
The `super` method is used inside a constructor and refers to the parent class. With this, one can access the parent class properties and methods. In the example above we use `super(brand)` in the Model subclass so it can get that `Car` superclasses properties.
39+
40+
{% hint style="info" %}
41+
Super classes are the main classes used while subclasses are classes that are extended from superclasses.
42+
{% endhint %}
3943

en/functions/set-interval.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
---
2+
chapter: 8
3+
pageNumber: 55
4+
Title: Set Interval
5+
---
6+
7+
18
# Set Interval
29
The set Interval method is a method used to call a function and add a delay time to it, in milliseconds, before the function will run again. For example, if you're making a function that generates a random color, you can use `setInterval()` to say how long the computer has to wait before the function runs again and generates another color. This is useful in making functions repeat.
310

en/functions/set-timeout.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
---
2+
chapter: 8
3+
pageNumber: 56
4+
Title: Set Timeout
5+
---
6+
17
# Set Timeout
28
The set timeout global method is used to add a timer (in milliseconds) before a function is ran.
39

0 commit comments

Comments
 (0)