"syntactic sugar" instead of "syntax sugar" (#1582)

"syntactic sugar" instead of "syntax sugar"
This commit is contained in:
Alexey Pyltsyn 2019-11-05 22:44:26 +03:00 committed by GitHub
commit 7ca5f53dae
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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.