You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 1-js/01-getting-started/2-manuals-specifications/article.md
+2-2
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,7 @@ But being that formalized, it's difficult to understand at first. So if you need
11
11
12
12
The latest draft is at <https://tc39.es/ecma262/>.
13
13
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>.
15
15
16
16
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.
17
17
@@ -28,7 +28,7 @@ Also, if you're in developing for the browser, then there are other specs covere
28
28
29
29
Also, we can use an internet search with phrases such as "RegExp MSDN" or "RegExp MSDN jscript".
30
30
31
-
## Feature support
31
+
## Compatibility tables
32
32
33
33
JavaScript is a developing language, new features get added regularly.
Copy file name to clipboardExpand all lines: 1-js/08-prototypes/04-prototype-methods/article.md
+6-5
Original file line number
Diff line number
Diff line change
@@ -179,7 +179,7 @@ Modern methods to setup and directly access the prototype are:
179
179
-[Object.getPrototypeOf(obj)](mdn:js/Object.getPrototypeOf) -- returns the `[[Prototype]]` of `obj` (same as `__proto__` getter).
180
180
-[Object.setPrototypeOf(obj, proto)](mdn:js/Object.setPrototypeOf) -- sets the `[[Prototype]]` of `obj` to `proto` (same as `__proto__` setter).
181
181
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.
183
183
184
184
So we can either use `Object.create(null)` to create a "very plain" object without `__proto__`, or stick to `Map` objects for that.
185
185
@@ -189,15 +189,16 @@ Also, `Object.create` provides an easy way to shallow-copy an object with all de
189
189
let clone =Object.create(Object.getPrototypeOf(obj), Object.getOwnPropertyDescriptors(obj));
190
190
```
191
191
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:
192
197
193
198
-[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.
194
199
-[Object.getOwnPropertySymbols(obj)](mdn:js/Object/getOwnPropertySymbols) -- returns an array of all own symbolic keys.
195
200
-[Object.getOwnPropertyNames(obj)](mdn:js/Object/getOwnPropertyNames) -- returns an array of all own string keys.
196
201
-[Reflect.ownKeys(obj)](mdn:js/Reflect/ownKeys) -- returns an array of all own keys.
197
202
-[obj.hasOwnProperty(key)](mdn:js/Object/hasOwnProperty): it returns `true` if `obj` has its own (not inherited) key named `key`.
198
203
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
-
203
204
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`.
Copy file name to clipboardExpand all lines: 1-js/09-classes/05-extend-natives/article.md
+3-10
Original file line number
Diff line number
Diff line change
@@ -70,21 +70,14 @@ Built-in objects have their own static methods, for instance `Object.keys`, `Arr
70
70
71
71
As we already know, native classes extend each other. For instance, `Array` extends `Object`.
72
72
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).
81
74
82
75
But built-in classes are an exception. They don't inherit statics from each other.
83
76
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.
85
78
86
79
Here's the picture structure for `Date` and `Object`:
87
80
88
81

89
82
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`.
Copy file name to clipboardExpand all lines: 1-js/09-classes/07-mixins/article.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -107,7 +107,7 @@ As `super` looks for parent methods in `[[HomeObject]].[[Prototype]]`, that mean
107
107
108
108
Now let's make a mixin for real life.
109
109
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.
111
111
112
112
- 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.
113
113
- 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.
Copy file name to clipboardExpand all lines: 1-js/99-js-misc/01-proxy/article.md
+1-2
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,3 @@
1
-
2
1
# Proxy and Reflect
3
2
4
3
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, ...);
175
174
numbers = new Proxy(numbers, ...);
176
175
```
177
176
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.
0 commit comments