Skip to content

Commit ef95c5b

Browse files
deyantomovsumn2u
authored andcommitted
fixed minor mistakes
1 parent 78031fc commit ef95c5b

File tree

1 file changed

+35
-40
lines changed

1 file changed

+35
-40
lines changed

en/interview-questions/intermediate-level.md

Lines changed: 35 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -315,12 +315,12 @@ Understanding truthy and falsy values allows us to write more concise and expres
315315
+ Public
316316
- Can be accessed from anywhere.
317317
+ Private
318-
- Indicated by prefixing them with the ```#``` symbol.
318+
- Indicated by prefixing members with the ```#``` symbol.
319319
- Cannot be accessed from instances or child classes.
320320
- Only available within the class itself.
321321
- Useful for information hiding.
322322
+ Protected
323-
- Indicated by prefixing them with the ```_``` symbol.
323+
- Indicated by prefixing members with the ```_``` symbol.
324324
- Can be accessed from the within the class and any class that inherits from it.
325325
- Useful for sharing state between classes.
326326

@@ -365,6 +365,8 @@ Example of encapsulation using getters and setters:
365365
// ...validate new ID
366366
this.#id = id;
367367
}
368+
369+
// ...
368370
}
369371
```
370372

@@ -393,54 +395,47 @@ Example of encapsulation using getters and setters:
393395

394396
class Person extends Animal {
395397
constructor(name) {
396-
// Call the parent class constructor
397-
super("Human");
398+
super("Human"); // Call the parent class constructor
398399
this.name = name;
399400
}
400401
}
401402
```
402-
- If no constructor is explicitly declared, a default one will be given to the class.
403-
404-
- Base class - If the class doesn't extend any other class, a default constructor will be assigned to it:
405-
406-
```javascript
407-
constructor() {}
408-
```
409-
410-
- Child class - If the class extends another class, it will inherit its constructor
411-
412-
```javascript
413-
class Vehicle {
414-
constructor(type) {
415-
this.type = type;
416-
}
417-
418-
move() {
419-
return `The ${this.type} is moving`;
420-
}
403+
+ iv. Default constructor - If no constructor is explicitly declared, a default one will be given to the class.
404+
- Base class - If the class doesn't extend any other class, a default constructor will be assigned to it:
405+
```javascript
406+
constructor() {}
407+
```
408+
- Child class - If the class extends another class, it will inherit its constructor
409+
```javascript
410+
class Vehicle {
411+
constructor(type) {
412+
this.type = type;
421413
}
422414

423-
class Car extends Vehicle {
424-
#model;
425-
426-
set model(model) {
427-
this.#model = model;
428-
}
429-
430-
drive() {
431-
`Driving ${this.#model}`;
432-
}
415+
move() {
416+
return `The ${this.type} is moving`;
433417
}
434-
```
418+
}
435419

436-
Even though the constructor is not explicitly declared, the class Car inherits it from the Vehicle class:
420+
class Car extends Vehicle {
421+
#model;
437422

438-
```javascript
439-
constructor(type) {
440-
super(type);
423+
set model(model) {
424+
this.#model = model;
425+
}
426+
427+
drive() {
428+
`Driving ${this.#model}`;
441429
}
442-
```
430+
}
431+
```
432+
Even though the constructor is not explicitly declared, the class Car inherits it from the Vehicle class:
433+
```javascript
434+
constructor(type) {
435+
super(type);
436+
}
437+
```
443438

444439
### 8.6. Static members vs Instance members
445440

446-
**Answer:** By default, properties and methods that we define inside a class, belong to each instance of the class that we create. We can also assign members to the class itself. Such members are called static, and are declared using the ```static``` keyword. They cannot be directly accessed on instances of the class.
441+
**Answer:** By default, properties and methods which we define inside a class belong to each instance of the class that we create. We can also assign members to the class itself. Such members are called static and are declared using the ```static``` keyword. They cannot be directly accessed on instances of the class.

0 commit comments

Comments
 (0)