refactor classes, add private, minor fixes

This commit is contained in:
Ilya Kantor 2019-03-05 18:44:28 +03:00
parent a0c07342ad
commit 1373f6158c
270 changed files with 1513 additions and 890 deletions

View file

@ -0,0 +1,16 @@
```js run untrusted
class FormatError extends SyntaxError {
constructor(message) {
super(message);
this.name = "FormatError";
}
}
let err = new FormatError("formatting error");
alert( err.message ); // formatting error
alert( err.name ); // FormatError
alert( err.stack ); // stack
alert( err instanceof SyntaxError ); // true
```

View file

@ -0,0 +1,22 @@
importance: 5
---
# Inherit from SyntaxError
Create a class `FormatError` that inherits from the built-in `SyntaxError` class.
It should support `message`, `name` and `stack` properties.
Usage example:
```js
let err = new FormatError("formatting error");
alert( err.message ); // formatting error
alert( err.name ); // FormatError
alert( err.stack ); // stack
alert( err instanceof FormatError ); // true
alert( err instanceof SyntaxError ); // true (because inherits from SyntaxError)
```