work
This commit is contained in:
parent
1bffa43db4
commit
057783d216
373 changed files with 203 additions and 190 deletions
17
1-js/3-object-basics/7-array/1-item-value/solution.md
Normal file
17
1-js/3-object-basics/7-array/1-item-value/solution.md
Normal file
|
@ -0,0 +1,17 @@
|
|||
The result is `4`:
|
||||
|
||||
|
||||
```js run
|
||||
let fruits = ["Apples", "Pear", "Orange"];
|
||||
|
||||
let shoppingCart = fruits;
|
||||
|
||||
shoppingCart.push("Banana");
|
||||
|
||||
*!*
|
||||
alert( fruits.length ); // 4
|
||||
*/!*
|
||||
```
|
||||
|
||||
That's because arrays are objects. So both `shoppingCart` and `fruits` are the references to the same array.
|
||||
|
19
1-js/3-object-basics/7-array/1-item-value/task.md
Normal file
19
1-js/3-object-basics/7-array/1-item-value/task.md
Normal file
|
@ -0,0 +1,19 @@
|
|||
importance: 3
|
||||
|
||||
---
|
||||
|
||||
# Is array copied?
|
||||
|
||||
What this code is going to show?
|
||||
|
||||
```js
|
||||
let fruits = ["Apples", "Pear", "Orange"];
|
||||
|
||||
// push a new value into the "copy"
|
||||
let shoppingCart = fruits;
|
||||
shoppingCart.push("Banana");
|
||||
|
||||
// what's in fruits?
|
||||
alert( fruits.length ); // ?
|
||||
```
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue