This commit is contained in:
Ilya Kantor 2019-08-27 08:04:58 +03:00
commit 6637d0ccae
5 changed files with 6 additions and 6 deletions

View file

@ -96,7 +96,7 @@ function pow(x, n) {
The maximal number of nested calls (including the first one) is called *recursion depth*. In our case, it will be exactly `n`.
The maximal recursion depth is limited by JavaScript engine. We can make sure about 10000, some engines allow more, but 100000 is probably out of limit for the majority of them. There are automatic optimizations that help alleviate this ("tail calls optimizations"), but they are not yet supported everywhere and work only in simple cases.
The maximal recursion depth is limited by JavaScript engine. We can rely on it being 10000, some engines allow more, but 100000 is probably out of limit for the majority of them. There are automatic optimizations that help alleviate this ("tail calls optimizations"), but they are not yet supported everywhere and work only in simple cases.
That limits the application of recursion, but it still remains very wide. There are many tasks where recursive way of thinking gives simpler code, easier to maintain.

View file

@ -313,7 +313,7 @@ Hopefully, the situation with outer variables is clear now. For most situations
## Environments in detail
Here's what's going on in the `makeCounter` example step-by-step, follow it to make sure that you know things in the very detail.
Here's what's going on in the `makeCounter` example step-by-step, follow it to make sure that you understand how it works in detail.
Please note the additional `[[Environment]]` property is covered here. We didn't mention it before for simplicity.

View file

@ -5,7 +5,7 @@ The global object provides variables and functions that are available anywhere.
In a browser it is named `window`, for Node.js it is `global`, for other environments it may have another name.
Recently, `globalThis` was added to the language, as a standartized name for a global object, that should be supported across all environments. In some browsers, namely non-Chromium Edge, `globalThis` is not yet supported, but can be easily polyfilled.
Recently, `globalThis` was added to the language, as a standardized name for a global object, that should be supported across all environments. In some browsers, namely non-Chromium Edge, `globalThis` is not yet supported, but can be easily polyfilled.
We'll use `window` here, assuming that our environment is a browser. If your script may run in other environments, it's better to use `globalThis` instead.

View file

@ -1,5 +1,5 @@
1. Yes, true. The element `elem.lastChild` is always the last one, it has no `nextSibling`.
2. No, wrong, because `elem.children[0]` is the first child *among elements*. But there may exist non-element nodes before it. So `previousSibling` may be a text node. Also, if there are no children, then trying to access `elem.children[0]`
2. No, wrong, because `elem.children[0]` is the first child *among elements*. But there may exist non-element nodes before it. So `previousSibling` may be a text node.
Please note: for both cases if there are no children, then there will be an error.

View file

@ -1,8 +1,8 @@
# Fetch users from GitHub
Create an async function `getUsers(names)`, that gets an array of GitHub logins, fetche the users from GitHub and returns an array of GitHub users.
Create an async function `getUsers(names)`, that gets an array of GitHub logins, fetches the users from GitHub and returns an array of GitHub users.
The GitHub url with user informaiton for the given `USERNAME` is: `https://api.github.com/users/USERNAME`.
The GitHub url with user information for the given `USERNAME` is: `https://api.github.com/users/USERNAME`.
There's a test example in the sandbox.