Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions code-snippets/hoisting.md
Original file line number Diff line number Diff line change
Expand Up @@ -344,4 +344,40 @@ line number 2 10

</li>
</li>

---

<li>

**What will be the output?**

```JS
function foo() {
let a = b = 0;
a++;
return a;
}

foo();
console.log(typeof a);
console.log(typeof b);
```

- A: `number \n number`
- B: `undefined \n number`
- C: `undefined \n undefined`
- D: `number \n undefined`

<br/>
<details>
<summary><b>Answer</b></summary>

<p>

#### Option: B

</p>

</details>
</li>
</ol>
25 changes: 25 additions & 0 deletions code-snippets/objects.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ console.log(TDK);
</li>

---

<li>

**What will be the output?**
Expand Down Expand Up @@ -134,5 +135,29 @@ console.log(greet({ name: 'Narendra Modi' }))

---

<li>

**What will be the output?**

```JS
const sample = ["xyz", "abc", "test", "ryan", "apple"];
delete sample[3];
console.log(sample.length);
```

- A: `4`
- B: `5`
- C: `Error updating the constant variable.`

<br/>
<details>
<summary><b>Answer</b></summary>
<p>

#### Option: B

</p>
</details>
</li>

</ol>
37 changes: 37 additions & 0 deletions code-snippets/promises.md
Original file line number Diff line number Diff line change
Expand Up @@ -323,4 +323,41 @@ p.catch(error => console.log(error.message))
</details>
</li>

---

<li>

**What's the order of output of the following Promise operation?**

```JS
console.log('initial');
setTimeout(function() {
console.log('setTimeout');
}, 0);
var promise = new Promise(function(resolve, reject) {
resolve();
});
promise.then(function(resolve) {
console.log('1st Promise');
})
.then(function(resolve) {
console.log('2nd Promise');
});
console.log('final');
```

- A: `initial \n 1st Promise \n 2nd Promise \n setTimeout \n final`
- B: `initial \n final \n 1st Promise \n 2nd Promise \n setTimeout`
- C: `initial \n setTimeout \n 1st Promise \n 2nd Promise \n final`
- D: `initial \n final \n 1st Promise \n setTimeout \n 2nd Promise`

<br/>
<details>
<summary><b>Answer</b></summary>
<p>

#### Option: B

</li>

</ol>