Skip to content

Commit 3caa911

Browse files
committed
fixes
1 parent 0b55d45 commit 3caa911

File tree

8 files changed

+21
-33
lines changed

8 files changed

+21
-33
lines changed

1-js/01-getting-started/2-manuals-specifications/article.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ But being that formalized, it's difficult to understand at first. So if you need
1111

1212
The latest draft is at <https://tc39.es/ecma262/>.
1313

14-
To read about new bleeding-edge features, that are "almost standard", see proposals at <https://github.com/tc39/proposals>.
14+
To read about new bleeding-edge features, including those that are "almost standard" (so-called "stage 3"), see proposals at <https://github.com/tc39/proposals>.
1515

1616
Also, if you're in developing for the browser, then there are other specs covered in the [second part](info:browser-environment) of the tutorial.
1717

@@ -28,7 +28,7 @@ Also, if you're in developing for the browser, then there are other specs covere
2828

2929
Also, we can use an internet search with phrases such as "RegExp MSDN" or "RegExp MSDN jscript".
3030

31-
## Feature support
31+
## Compatibility tables
3232

3333
JavaScript is a developing language, new features get added regularly.
3434

1-js/08-prototypes/04-prototype-methods/article.md

+6-5
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ Modern methods to setup and directly access the prototype are:
179179
- [Object.getPrototypeOf(obj)](mdn:js/Object.getPrototypeOf) -- returns the `[[Prototype]]` of `obj` (same as `__proto__` getter).
180180
- [Object.setPrototypeOf(obj, proto)](mdn:js/Object.setPrototypeOf) -- sets the `[[Prototype]]` of `obj` to `proto` (same as `__proto__` setter).
181181

182-
The built-in `__proto__` getter/setter is unsafe if we'd want to put user-generated keys in to an object. Just because a user may enter "__proto__" as the key, and there'll be an error with hopefully easy, but generally unpredictable consequences.
182+
The built-in `__proto__` getter/setter is unsafe if we'd want to put user-generated keys in to an object. Just because a user may enter `"__proto__"` as the key, and there'll be an error, with hopefully light, but generally unpredictable consequences.
183183

184184
So we can either use `Object.create(null)` to create a "very plain" object without `__proto__`, or stick to `Map` objects for that.
185185

@@ -189,15 +189,16 @@ Also, `Object.create` provides an easy way to shallow-copy an object with all de
189189
let clone = Object.create(Object.getPrototypeOf(obj), Object.getOwnPropertyDescriptors(obj));
190190
```
191191

192+
We also made it clear that `__proto__` is a getter/setter for `[[Prototype]]` and resides in `Object.prototype`, just as other methods.
193+
194+
We can create an object without a prototype by `Object.create(null)`. Such objects are used as "pure dictionaries", they have no issues with `"__proto__"` as the key.
195+
196+
Other methods:
192197

193198
- [Object.keys(obj)](mdn:js/Object/keys) / [Object.values(obj)](mdn:js/Object/values) / [Object.entries(obj)](mdn:js/Object/entries) -- returns an array of enumerable own string property names/values/key-value pairs.
194199
- [Object.getOwnPropertySymbols(obj)](mdn:js/Object/getOwnPropertySymbols) -- returns an array of all own symbolic keys.
195200
- [Object.getOwnPropertyNames(obj)](mdn:js/Object/getOwnPropertyNames) -- returns an array of all own string keys.
196201
- [Reflect.ownKeys(obj)](mdn:js/Reflect/ownKeys) -- returns an array of all own keys.
197202
- [obj.hasOwnProperty(key)](mdn:js/Object/hasOwnProperty): it returns `true` if `obj` has its own (not inherited) key named `key`.
198203

199-
We also made it clear that `__proto__` is a getter/setter for `[[Prototype]]` and resides in `Object.prototype`, just as other methods.
200-
201-
We can create an object without a prototype by `Object.create(null)`. Such objects are used as "pure dictionaries", they have no issues with `"__proto__"` as the key.
202-
203204
All methods that return object properties (like `Object.keys` and others) -- return "own" properties. If we want inherited ones, then we can use `for..in`.

1-js/09-classes/05-extend-natives/article.md

+3-10
Original file line numberDiff line numberDiff line change
@@ -70,21 +70,14 @@ Built-in objects have their own static methods, for instance `Object.keys`, `Arr
7070

7171
As we already know, native classes extend each other. For instance, `Array` extends `Object`.
7272

73-
Normally, when one class extends another, both static and non-static methods are inherited.
74-
75-
So, if `Rabbit extends Animal`, then:
76-
77-
1. `Rabbit.methods` are callable for `Animal.methods`, because `Rabbit.[[Prototype]] = Animal`.
78-
2. `new Rabbit().methods` are also available, because `Rabbit.prototype.[[Prototype]] = Animal.prototype`.
79-
80-
That's thoroughly explained in the chapter [](info:static-properties-methods#statics-and-inheritance).
73+
Normally, when one class extends another, both static and non-static methods are inherited. That was thoroughly explained in the chapter [](info:static-properties-methods#statics-and-inheritance).
8174

8275
But built-in classes are an exception. They don't inherit statics from each other.
8376

84-
For example, both `Array` and `Date` inherit from `Object`, so their instances have methods from `Object.prototype`. But `Array.[[Prototype]]` does not point to `Object`. So there's `Object.keys()`, but not `Array.keys()` and `Date.keys()`.
77+
For example, both `Array` and `Date` inherit from `Object`, so their instances have methods from `Object.prototype`. But `Array.[[Prototype]]` does not reference `Object`, so there's no `Array.keys()` and `Date.keys()` static methods.
8578

8679
Here's the picture structure for `Date` and `Object`:
8780

8881
![](object-date-inheritance.png)
8982

90-
Note, there's no link between `Date` and `Object`. Both `Object` and `Date` exist independently. `Date.prototype` inherits from `Object.prototype`, but that's all.
83+
As you can see, there's no link between `Date` and `Object`. They are independent, only `Date.prototype` inherits from `Object.prototype`.

1-js/09-classes/07-mixins/article.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ As `super` looks for parent methods in `[[HomeObject]].[[Prototype]]`, that mean
107107

108108
Now let's make a mixin for real life.
109109

110-
An important feature of many browser objects (not only) is that they can generate events. Events is a great way to "broadcast information" to anyone who wants it. So let's make a mixin that allows to easily add event-related functions to any class/object.
110+
An important feature of many browser objects (for instance) is that they can generate events. Events is a great way to "broadcast information" to anyone who wants it. So let's make a mixin that allows to easily add event-related functions to any class/object.
111111

112112
- The mixin will provide a method `.trigger(name, [...data])` to "generate an event" when something important happens to it. The `name` argument is a name of the event, optionally followed by additional arguments with event data.
113113
- Also the method `.on(name, handler)` that adds `handler` function as the listener to events with the given name. It will be called when an event with the given `name` triggers, and get the arguments from `.trigger` call.

1-js/12-generators-iterators/1-generators/article.md

-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
# Generators
32

43
Regular functions return only one, single value (or nothing).
@@ -224,8 +223,6 @@ let range = {
224223
alert( [...range] ); // 1,2,3,4,5
225224
```
226225

227-
The `range` object is now iterable.
228-
229226
That works, because `range[Symbol.iterator]()` now returns a generator, and generator methods are exactly what `for..of` expects:
230227
- it has `.next()` method
231228
- that returns values in the form `{value: ..., done: true/false}`

1-js/13-modules/03-modules-dynamic-imports/article.md

+7-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
# Dynamic imports
32

43
Export and import statements that we covered in previous chapters are called "static".
@@ -65,10 +64,9 @@ let {hi, bye} = await import('./say.js');
6564

6665
hi();
6766
bye();
68-
6967
```
7068
71-
Or, for the default export:
69+
Or, if `say.js` has the default export:
7270
7371
```js
7472
// 📁 say.js
@@ -77,12 +75,12 @@ export default function() {
7775
}
7876
```
7977
80-
To import it, we need to get `default` property of the module object, as explained in the [previous chapter](info:import-export).
78+
...Then, in order to access it, we can use `default` property of the module object, as explained in the [previous chapter](info:import-export).
8179
8280
So, the dynamic import will be like this:
8381
8482
```js
85-
let {default: say} = await import('./say.js'); // map .default to say variable
83+
let {default: say} = await import('./say.js'); // save .default property in say variable
8684

8785
say();
8886
```
@@ -91,12 +89,12 @@ Here's the full example:
9189
9290
[codetabs src="say" current="index.html"]
9391
94-
So, dynamic imports are very simple to use, and they allow to import modules at run-time.
95-
96-
Also, dynamic imports work in regular scripts, they don't require `script type="module"`.
92+
```smart
93+
Dynamic imports work in regular scripts, they don't require `script type="module"`.
94+
```
9795
9896
```smart
9997
Although `import()` looks like a function call, it's a special syntax that just happens to use parentheses (similar to `super()`).
10098

101-
That means that import doesn't inherit from `Function.prototype` so we cannot call or apply it.
99+
So we can't copy `import` to a variable or use `.call/apply` with it.
102100
```

1-js/99-js-misc/01-proxy/article.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
# Proxy and Reflect
32

43
A *proxy* wraps another object and intercepts operations, like reading/writing properties and others, optionally handling them on its own, or transparently allowing the object to handle them.
@@ -175,7 +174,7 @@ dictionary = new Proxy(dictionary, ...);
175174
numbers = new Proxy(numbers, ...);
176175
```
177176
178-
The proxy should totally replace the target object everywhere. No one should ever reference the target object after it got proxied. Otherwise it 's easy to mess up.
177+
The proxy should totally replace the target object everywhere. No one should ever reference the target object after it got proxied. Otherwise it's easy to mess up.
179178
````
180179

181180
## Validation with "set" trap

2-ui/1-document/01-browser-environment/article.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ function sayHi() {
2222
alert("Hello");
2323
}
2424

25-
// global functions are methods of the global objecct:
25+
// global functions are methods of the global object:
2626
window.sayHi();
2727
```
2828

0 commit comments

Comments
 (0)