Merge pull request #1890 from Violet-Bora-Lee/master

minor fixes
This commit is contained in:
Ilya Kantor 2020-05-06 11:21:18 +03:00 committed by GitHub
commit 405032ef32
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 7 additions and 7 deletions

View file

@ -121,7 +121,7 @@ This leads to some interesting usage compared to a "pure, classical, boolean-onl
Another feature of OR `||` operator is the so-called "short-circuit" evaluation.
It means that `||` processes its arguments until the first truthy value is reached, and then the value is returned immediately, without even touching the other argument.
It means that `||` processes its arguments until the first truthy value is reached, and then the value is returned immediately, without even touching the other argument.
That importance of this feature becomes obvious if an operand isn't just a value, but an expression with a side effect, such as a variable assignment or a function call.

View file

@ -360,7 +360,7 @@ alert( *!*key*/!* in user ); // true, property "age" exists
Why does the `in` operator exist? Isn't it enough to compare against `undefined`?
Well, most of the time the comparison with `undefined` works fine. But there's But there's a special case when it fails, but `"in"` works correctly.
Well, most of the time the comparison with `undefined` works fine. But there's a special case when it fails, but `"in"` works correctly.
It's when an object property exists, but stores `undefined`:

View file

@ -9,7 +9,7 @@ arr.push(function() {
alert( this );
})
arr[2](); // "a","b",function
arr[2](); // a,b,function(){...}
```
The array has 3 values: initially it had two, plus the function.

View file

@ -156,7 +156,7 @@ In computer science the data structure that allows this, is called [deque](https
`shift`
: Extracts the first element of the array and returns it:
```js
```js run
let fruits = ["Apple", "Orange", "Pear"];
alert( fruits.shift() ); // remove Apple and alert it
@ -167,7 +167,7 @@ In computer science the data structure that allows this, is called [deque](https
`unshift`
: Add the element to the beginning of the array:
```js
```js run
let fruits = ["Orange", "Pear"];
fruits.unshift('Apple');

View file

@ -225,11 +225,11 @@ But there's a subtle difference between `Array.from(obj)` and `[...obj]`:
So, for the task of turning something into an array, `Array.from` tends to be more universal.
## Get a new copy of an object/array
## Get a new copy of an array/object
Remember when we talked about `Object.assign()` [in the past](https://javascript.info/object#cloning-and-merging-object-assign)?
It is possible to do the same thing with the spread operator!
It is possible to do the same thing with the spread syntax.
```js run
let arr = [1, 2, 3];