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
Except `undefined`, `null`, `false`, `NaN`, `''`, `0`, `-0`, all of the values, including objects, are converted to `true`.
190
-
191
-
## Objects to Primitive Types
192
-
193
-
When objects are converted, `valueOf` and `toString` will be called, respectively in order. These two methods can also be overridden.
194
-
195
-
```js
196
-
let a = {
197
-
valueOf() {
198
-
return0
199
-
}
200
-
}
201
-
```
202
-
203
-
## Arithmetic Operators
204
-
205
-
Only for additions, if one of the parameters is a string, the other will be converted to the string as well. For all other operations, as long as one of the parameters is a number, the other will be converted to a number.
206
-
207
-
Additions will invoke three types of type conversions: to primitive types, to numbers, and to string.
@@ -816,7 +742,7 @@ We can consider how to implement them from the following points
816
742
* If the first parameter isn’t passed, then the first parameter will default to `window`
817
743
* Change what `this` refers to, which makes new object capable of executing the function. Then let’s think like this: add a function to a new object and then delete it after the execution.
818
744
819
-
```js
745
+
```js
820
746
Function.prototype.myCall=function (context) {
821
747
var context = context ||window
822
748
// Add an property to the `context`
@@ -834,7 +760,7 @@ Function.prototype.myCall = function (context) {
834
760
835
761
The above is the main idea of simulating `call`, and the implementation of `apply` is similar.
Copy file name to clipboardExpand all lines: Network/Network_en.md
+7-4
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,7 @@
11
11
-[Header](#header)
12
12
-[State machine](#state-machine)
13
13
-[Three-way handshake in opening a connection](#three-way-handshake-in-opening-a-connection)
14
-
-[Four-handshake of disconnect.](#four-handshake-of-disconnect)
14
+
-[Four-handshake of disconnect](#four-handshake-of-disconnect)
15
15
-[ARQ protocol](#arq-protocol)
16
16
-[Stop-and-Wait ARQ](#stop-and-wait-arq)
17
17
-[Continuous ARQ](#continuous-arq)
@@ -26,13 +26,14 @@
26
26
-[HTTP](#http)
27
27
-[Difference between POST & GET](#difference-between-post--get)
28
28
-[Common Status Code](#common-status-code)
29
+
-[Common Fields](#common-fields)
29
30
-[HTTPS](#https)
30
31
-[TLS](#tls)
31
32
-[HTTP/2](#http2)
32
33
-[Binary Transport](#binary-transport)
33
34
-[MultiPlexing](#multiplexing)
34
35
-[Header compression](#header-compression)
35
-
-[server push](#server-push)
36
+
-[Server push](#server-push)
36
37
-[QUIC](#quic)
37
38
-[DNS](#dns)
38
39
-[What happens when you navigate to an URL](#what-happens-when-you-navigate-to-an-url)
@@ -130,7 +131,7 @@ Imagine that, the client sends a connect request called A, but the network is ba
130
131
131
132
PS: Through connecting, if any end is offline, it needs to retransmit, generally, five times. You can limit the times of retransmitting or refuse the request if can't handle it.
@@ -445,7 +448,7 @@ In HTTP/1. X, we transfer data of the header by plain text. In the case where th
445
448
446
449
In HTTP 2.0, the header of the transport was encoded using the HPACK compression format, reducing the size of the header. The index table is maintained at both ends to record the occurrence of the header. The key name of the already recorded header can be transmitted during the transmission. After receives the data, the corresponding value can be found by the key.
447
450
448
-
## server push
451
+
## Server push
449
452
450
453
In HTTP/2, the server can push resources to the client without the client having to request. Imagine that, something in the server is necessary for the client, so the server can push the associated resources ahead of time to reduce the delay time. By the way, we can also use `pre-fetch` if the client is compatible.
Copy file name to clipboardExpand all lines: Safety/safety-en.md
+2-2
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@
10
10
-[How to attack](#how-to-attack-1)
11
11
-[How to defend](#how-to-defend-1)
12
12
-[SameSite](#samesite)
13
-
-[Verify Referer](#verify--referer)
13
+
-[Verify Referer](#verify-referer)
14
14
-[Token](#token)
15
15
-[Password security](#password-security)
16
16
-[Add salt](#add-salt)
@@ -136,7 +136,7 @@ There are several rules for defending against CSRF:
136
136
137
137
The `SameSite` attribute can be set on cookies. This attribute sets the cookie not to be sent along with cross-domain requests. This attribute can greatly reduce the CSRF attack, but this attribute is currently not compatible with all browsers.
138
138
139
-
#### Verify Referer
139
+
#### Verify Referer
140
140
141
141
For requests that need protection against CSRF, we can verify the Referer to determine if the request was initiated by a third-party website.
0 commit comments