Skip to content

Commit a6b5a5e

Browse files
committed
Merge origin
2 parents 1cd02bd + 1db860e commit a6b5a5e

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

README.md

+15-15
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
I post daily multiple choice JavaScript questions on my [Instagram](https://www.instagram.com/theavocoder), which I'll also post here!
44

5-
From basic to advanced: test how well you know JavaScript, refresh your knowledge a bit, or prepare for your coding interview! :muscle: :rocket:
5+
From basic to advanced: test how well you know JavaScript, refresh your knowledge a bit, or prepare for your coding interview! :muscle: :rocket: I update this repo weekly with new questions.
66

77
The answers are in the collapsed sections below the questions, simply click on them to expand it. Good luck :heart:
88

@@ -160,7 +160,7 @@ JavaScript interprets (or unboxes) statements. When we use bracket notation, it
160160

161161
`mouse[bird.size]`: First it evaluates `bird.size`, which is `"small"`. `mouse["small"]` returns `true`
162162

163-
However, with dot notation. this doesn't happen. `mouse` does not have a key called `bird`, which means that `mouse.bird` is `undefined`. Then, we ask for the `size` using dot notation: `mouse.bird.size`. Since `mouse.bird` is `undefinfed`, we're actually asking `undefined.size`. This isn't valid, and will throw an error similar to `Cannot read property "size" of undefined`.
163+
However, with dot notation, this doesn't happen. `mouse` does not have a key called `bird`, which means that `mouse.bird` is `undefined`. Then, we ask for the `size` using dot notation: `mouse.bird.size`. Since `mouse.bird` is `undefined`, we're actually asking `undefined.size`. This isn't valid, and will throw an error similar to `Cannot read property "size" of undefined`.
164164

165165
</p>
166166
</details>
@@ -352,7 +352,7 @@ console.log(member.getFullName());
352352

353353
#### Answer: A
354354

355-
You can't add properties to a constructor like you can with regular objects. If you want to add a feature to all object at once, you have to use the prototype instead. So in this case,
355+
You can't add properties to a constructor like you can with regular objects. If you want to add a feature to all objects at once, you have to use the prototype instead. So in this case,
356356

357357
```javascript
358358
Person.prototype.getFullName = function() {
@@ -392,7 +392,7 @@ console.log(sarah);
392392

393393
#### Answer: A
394394

395-
For `sarah`, we didn't use the `new` keyword.When using `new`, it refers to the new empty object we create. However, if you don't add `new` it refers to the **global object**!
395+
For `sarah`, we didn't use the `new` keyword. When using `new`, it refers to the new empty object we create. However, if you don't add `new` it refers to the **global object**!
396396

397397
We said that `this.firstName` equals `"Sarah"` and `this.lastName` equals `"Smith"`. What we actually did, is defining `global.firstName = 'Sarah'` and `global.lastName = 'Smith'`. `sarah` itself is left `undefined`.
398398

@@ -519,9 +519,9 @@ const age = 21;
519519
getPersonInfo`${person} is ${age} years old`;
520520
```
521521

522-
- A: `Lydia` `21` `["", "is", "years old"]`
523-
- B: `["", "is", "years old"]` `Lydia` `21`
524-
- C: `Lydia` `["", "is", "years old"]` `21`
522+
- A: `"Lydia"` `21` `["", " is ", " years old"]`
523+
- B: `["", " is ", " years old"]` `"Lydia"` `21`
524+
- C: `"Lydia"` `["", " is ", " years old"]` `21`
525525

526526
<details><summary><b>Answer</b></summary>
527527
<p>
@@ -591,7 +591,7 @@ getAge(21);
591591

592592
#### Answer: C
593593

594-
The spread operator (`...args`.) retrusn an array with arguments. An array is an object, so `typeof args` returns `"object"`
594+
The spread operator (`...args`.) returns an array with arguments. An array is an object, so `typeof args` returns `"object"`
595595

596596
</p>
597597
</details>
@@ -620,7 +620,7 @@ getAge();
620620

621621
#### Answer: C
622622

623-
With `"use strict"`, you can make sure that you don't accidentally declare global variables. We never declared the variable `age`, and since we use `"use strict"`, it will throw a reference error. It we didn't use `"use strict"`, it would have worked, since the property `age` would have gotten added to the global object.
623+
With `"use strict"`, you can make sure that you don't accidentally declare global variables. We never declared the variable `age`, and since we use `"use strict"`, it will throw a reference error. If we didn't use `"use strict"`, it would have worked, since the property `age` would have gotten added to the global object.
624624

625625
</p>
626626
</details>
@@ -658,7 +658,7 @@ sessionStorage.setItem("cool_secret", 123);
658658

659659
- A: Forever, the data doesn't get lost.
660660
- B: When the user closes the tab.
661-
- C: When the uses closes the entire browser, not only the tab.
661+
- C: When the user closes the entire browser, not only the tab.
662662
- D: When the user shuts off their computer.
663663

664664
<details><summary><b>Answer</b></summary>
@@ -725,7 +725,7 @@ set.has(1);
725725

726726
#### Answer: C
727727

728-
All object keys (excluding Symbols) are strings under the hood, even if you don't type it youself as a string. This is why `obj.hasOwnProperty('1')` also returns true.
728+
All object keys (excluding Symbols) are strings under the hood, even if you don't type it yourself as a string. This is why `obj.hasOwnProperty('1')` also returns true.
729729

730730
It doesn't work that way for a set. There is no `'1'` in our set: `set.has('1')` returns `false`. It has the numeric type `1`, `set.has(1)` returns `true`.
731731

@@ -891,7 +891,7 @@ We have a `setTimeout` function and invoked it first. Yet, it was logged last.
891891

892892
This is because in browsers, we don't just have the runtime engine, we also have something called a `WebAPI`. The `WebAPI` gives us the `setTimeout` function to start with, and for example the DOM.
893893

894-
After the _callback_ is pushed to the WebAPI,the `setTimeout` function itself (but not the callback!) is popped off the stack.
894+
After the _callback_ is pushed to the WebAPI, the `setTimeout` function itself (but not the callback!) is popped off the stack.
895895

896896
<img src="https://i.imgur.com/X5wsHOg.png" width="200">
897897

@@ -907,7 +907,7 @@ The WebAPI can't just add stuff to the stack whenever it's ready. Instead, it pu
907907

908908
<img src="https://i.imgur.com/NSnDZmU.png" width="200">
909909

910-
This is where an event loop starts to work. An **event loop** looks looks at the stack and task queue. If the stack is empty, it takes the first thing on the queue and pushes it onto the stack.
910+
This is where an event loop starts to work. An **event loop** looks at the stack and task queue. If the stack is empty, it takes the first thing on the queue and pushes it onto the stack.
911911

912912
<img src="https://i.imgur.com/uyiScAI.png" width="200">
913913

@@ -1047,8 +1047,8 @@ undefined;
10471047
```
10481048

10491049
- A: `0`, `''`, `undefined`
1050-
- B: `0`, `new Number(0)`, `''`, `new Boolean(false`, `undefined`
1051-
- C: `0`, `''`, `new Boolean(false0)`, `undefined`
1050+
- B: `0`, `new Number(0)`, `''`, `new Boolean(false)`, `undefined`
1051+
- C: `0`, `''`, `new Boolean(false)`, `undefined`
10521052
- D: All of them are falsy
10531053

10541054
<details><summary><b>Answer</b></summary>

0 commit comments

Comments
 (0)