typo
This commit is contained in:
parent
63243255a0
commit
61bc426051
5 changed files with 11 additions and 11 deletions
|
@ -86,7 +86,7 @@ Here's the full list:
|
|||
|`\\`|Backslash|
|
||||
|`\t`|Tab|
|
||||
|`\b`, `\f`, `\v`| Backspace, Form Feed, Vertical Tab -- kept for compatibility, not used nowadays. |
|
||||
|`\xXX`|Unicode character with the given hexadimal unicode `XX`, e.g. `'\x7A'` is the same as `'z'`.|
|
||||
|`\xXX`|Unicode character with the given hexadecimal unicode `XX`, e.g. `'\x7A'` is the same as `'z'`.|
|
||||
|`\uXXXX`|A unicode symbol with the hex code `XXXX` in UTF-16 encoding, for instance `\u00A9` -- is a unicode for the copyright symbol `©`. It must be exactly 4 hex digits. |
|
||||
|`\u{X…XXXXXX}` (1 to 6 hex characters)|A unicode symbol with the given UTF-32 encoding. Some rare characters are encoded with two unicode symbols, taking 4 bytes. This way we can insert long codes. |
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ alert(obj.__proto__ === Object.prototype); // true
|
|||
// obj.toString === obj.__proto__.toString == Object.prototype.toString
|
||||
```
|
||||
|
||||
Please note that there is no additional `[[Prototype]]` in the chain above `Object.prototype`:
|
||||
Please note that there is no more `[[Prototype]]` in the chain above `Object.prototype`:
|
||||
|
||||
```js run
|
||||
alert(Object.prototype.__proto__); // null
|
||||
|
@ -46,9 +46,9 @@ alert(Object.prototype.__proto__); // null
|
|||
|
||||
Other built-in objects such as `Array`, `Date`, `Function` and others also keep methods in prototypes.
|
||||
|
||||
For instance, when we create an array `[1, 2, 3]`, the default `new Array()` constructor is used internally. So the array data is written into the new object, and `Array.prototype` becomes its prototype and provides methods. That's very memory-efficient.
|
||||
For instance, when we create an array `[1, 2, 3]`, the default `new Array()` constructor is used internally. So `Array.prototype` becomes its prototype and provides methods. That's very memory-efficient.
|
||||
|
||||
By specification, all of the built-in prototypes have `Object.prototype` on the top. Sometimes people say that "everything inherits from objects".
|
||||
By specification, all of the built-in prototypes have `Object.prototype` on the top. That's why some people say that "everything inherits from objects".
|
||||
|
||||
Here's the overall picture (for 3 built-ins to fit):
|
||||
|
||||
|
@ -122,7 +122,7 @@ String.prototype.show = function() {
|
|||
During the process of development, we may have ideas for new built-in methods we'd like to have, and we may be tempted to add them to native prototypes. But that is generally a bad idea.
|
||||
|
||||
```warn
|
||||
Prototypes are global, so it's easy to get a conflict. If two libraries add a method `String.prototype.show`, then one of them will be overwriting the other.
|
||||
Prototypes are global, so it's easy to get a conflict. If two libraries add a method `String.prototype.show`, then one of them will be overwriting the method of the other.
|
||||
|
||||
So, generally, modifying a native prototype is considered a bad idea.
|
||||
```
|
||||
|
@ -144,7 +144,7 @@ if (!String.prototype.repeat) { // if there's no such method
|
|||
|
||||
// actually, the code should be a little bit more complex than that
|
||||
// (the full algorithm is in the specification)
|
||||
// but even an imperfect polyfill is often considered good enough
|
||||
// but even an imperfect polyfill is often considered good enough for use
|
||||
return new Array(n + 1).join(this);
|
||||
};
|
||||
}
|
||||
|
@ -161,7 +161,7 @@ That's when we take a method from one object and copy it into another.
|
|||
|
||||
Some methods of native prototypes are often borrowed.
|
||||
|
||||
For instance, if we're making an array-like object, we may want to copy some array methods to it.
|
||||
For instance, if we're making an array-like object, we may want to copy some `Array` methods to it.
|
||||
|
||||
E.g.
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
We need to look for `#` followed by 6 hexadimal characters.
|
||||
We need to look for `#` followed by 6 hexadecimal characters.
|
||||
|
||||
A hexadimal character can be described as `pattern:[0-9a-fA-F]`. Or if we use the `i` flag, then just `pattern:[0-9a-f]`.
|
||||
A hexadecimal character can be described as `pattern:[0-9a-fA-F]`. Or if we use the `i` flag, then just `pattern:[0-9a-f]`.
|
||||
|
||||
Then we can look for 6 of them using the quantifier `pattern:{6}`.
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Regexp for HTML colors
|
||||
|
||||
Create a regexp to search HTML-colors written as `#ABCDEF`: first `#` and then 6 hexadimal characters.
|
||||
Create a regexp to search HTML-colors written as `#ABCDEF`: first `#` and then 6 hexadecimal characters.
|
||||
|
||||
An example of use:
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ For the full Unicode Character Database in text format (along with all propertie
|
|||
|
||||
There are also other derived categories, like:
|
||||
- `Alphabetic` (`Alpha`), includes Letters `L`, plus letter numbers `Nl` (e.g. roman numbers Ⅻ), plus some other symbols `Other_Alphabetic` (`OAltpa`).
|
||||
- `Hex_Digit` includes hexadimal digits: `0-9`, `a-f`.
|
||||
- `Hex_Digit` includes hexadecimal digits: `0-9`, `a-f`.
|
||||
- ...Unicode is a big beast, it includes a lot of properties.
|
||||
|
||||
For instance, let's look for a 6-digit hex number:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue