From e52705e012caabe0dddab27e68ee2a8fc9f2049b Mon Sep 17 00:00:00 2001 From: Ilya Kantor Date: Fri, 2 Aug 2019 13:48:10 +0300 Subject: [PATCH] fixes --- .../10-ifelse/5-rewrite-if-question/task.md | 5 +++-- 1-js/06-advanced-functions/03-closure/article.md | 2 +- 5-network/11-websocket/article.md | 8 +++----- 5-network/12-server-sent-events/article.md | 2 +- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/1-js/02-first-steps/10-ifelse/5-rewrite-if-question/task.md b/1-js/02-first-steps/10-ifelse/5-rewrite-if-question/task.md index 684e239f..6bdf8453 100644 --- a/1-js/02-first-steps/10-ifelse/5-rewrite-if-question/task.md +++ b/1-js/02-first-steps/10-ifelse/5-rewrite-if-question/task.md @@ -4,13 +4,14 @@ importance: 5 # Rewrite 'if' into '?' -Rewrite this `if` using the ternary operator `'?'`: +Rewrite this `if` using the conditional operator `'?'`: ```js +let result; + if (a + b < 4) { result = 'Below'; } else { result = 'Over'; } ``` - diff --git a/1-js/06-advanced-functions/03-closure/article.md b/1-js/06-advanced-functions/03-closure/article.md index 53e1484a..f3268441 100644 --- a/1-js/06-advanced-functions/03-closure/article.md +++ b/1-js/06-advanced-functions/03-closure/article.md @@ -195,7 +195,7 @@ And if a function is called multiple times, then each invocation will have its o ``` ```smart header="Lexical Environment is a specification object" -"Lexical Environment" is a specification object. We can't get this object in our code and manipulate it directly. JavaScript engines also may optimize it, discard variables that are unused to save memory and perform other internal tricks, but the visible behavior should be as described. +"Lexical Environment" is a specification object: it only exists "theoretically" in the [language specification](https://tc39.es/ecma262/#sec-lexical-environments) to describe how things work. We can't get this object in our code and manipulate it directly. JavaScript engines also may optimize it, discard variables that are unused to save memory and perform other internal tricks, as long as the visible behavior remains as described. ``` diff --git a/5-network/11-websocket/article.md b/5-network/11-websocket/article.md index 4fdb4067..2ae9dc2c 100644 --- a/5-network/11-websocket/article.md +++ b/5-network/11-websocket/article.md @@ -1,8 +1,6 @@ # WebSocket -The `WebSocket` protocol, described in the specification [RFC 6455](http://tools.ietf.org/html/rfc6455) provides a way to exchange data between browser and server via a persistent connection. - -Once a websocket connection is established, both client and server may send the data to each other. +The `WebSocket` protocol, described in the specification [RFC 6455](http://tools.ietf.org/html/rfc6455) provides a way to exchange data between browser and server via a persistent connection. The data can be passed in both directions as "packets", without breaking the connection and additional HTTP-requests. WebSocket is especially great for services that require continuous data exchange, e.g. online games, real-time trading systems and so on. @@ -21,7 +19,7 @@ The `wss://` protocol not only encrypted, but also more reliable. That's because `ws://` data is not encrypted, visible for any intermediary. Old proxy servers do not know about WebSocket, they may see "strange" headers and abort the connection. -On the other hand, `wss://` is WebSocket over TLS, (same as HTTPS is HTTP over TLS), the transport security layer encrypts the data at sender and decrypts at the receiver, so it passes encrypted through proxies. They can't see what's inside and let it through. +On the other hand, `wss://` is WebSocket over TLS, (same as HTTPS is HTTP over TLS), the transport security layer encrypts the data at sender and decrypts at the receiver. So data packets are passed encrypted through proxies. They can't see what's inside and let them through. ``` Once the socket is created, we should listen to events on it. There are totally 4 events: @@ -38,7 +36,7 @@ Here's an example: let socket = new WebSocket("wss://javascript.info/article/websocket/demo/hello"); socket.onopen = function(e) { - alert("[open] Connection established, send -> server"); + alert("[open] Connection established, send the data -> server"); socket.send("My name is John"); }; diff --git a/5-network/12-server-sent-events/article.md b/5-network/12-server-sent-events/article.md index e7ef66b7..2f88190f 100644 --- a/5-network/12-server-sent-events/article.md +++ b/5-network/12-server-sent-events/article.md @@ -266,6 +266,6 @@ A message may have following fields: - `data:` -- message body, a sequence of multiple `data` is interpreted as a single message, with `\n` between the parts. - `id:` -- renews `lastEventId`, sent in `Last-Event-ID` on reconnect. - `retry:` -- recommends a retry delay for reconnections in ms. There's no way to set it from JavaScript. -- `event:` -- even name, must precede `data:`. +- `event:` -- event name, must precede `data:`. A message may include one or more fields in any order, but `id:` usually goes the last.