"syntactic sugar" instead of "syntax sugar" (#1582)
"syntactic sugar" instead of "syntax sugar"
This commit is contained in:
commit
7ca5f53dae
1 changed files with 3 additions and 3 deletions
|
@ -116,9 +116,9 @@ alert(User.prototype.sayHi); // alert(this.name);
|
|||
alert(Object.getOwnPropertyNames(User.prototype)); // constructor, sayHi
|
||||
```
|
||||
|
||||
## Not just a syntax sugar
|
||||
## Not just a syntactic sugar
|
||||
|
||||
Sometimes people say that `class` is a "syntax sugar" (syntax that is designed to make things easier to read, but doesn't introduce anything new), because we could actually declare the same without `class` keyword at all:
|
||||
Sometimes people say that `class` is a "syntactic sugar" (syntax that is designed to make things easier to read, but doesn't introduce anything new), because we could actually declare the same without `class` keyword at all:
|
||||
|
||||
```js run
|
||||
// rewriting class User in pure functions
|
||||
|
@ -140,7 +140,7 @@ let user = new User("John");
|
|||
user.sayHi();
|
||||
```
|
||||
|
||||
The result of this definition is about the same. So, there are indeed reasons why `class` can be considered a syntax sugar to define a constructor together with its prototype methods.
|
||||
The result of this definition is about the same. So, there are indeed reasons why `class` can be considered a syntactic sugar to define a constructor together with its prototype methods.
|
||||
|
||||
Still, there are important differences.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue