Skip to content

Commit 8a1bf4d

Browse files
authored
Added question number 39 to 40
1 parent ff538f2 commit 8a1bf4d

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -681,3 +681,34 @@ console.log(firstName);
681681

682682
**[:top: Scroll to Top](#javascript-output-based-interview-questions)**
683683

684+
**39. What will be the output**
685+
```js
686+
var a = 10;
687+
let a = 20;
688+
console.log(a)
689+
```
690+
<details>
691+
<summary><b>View Answer</b></summary>
692+
<ul>
693+
<li><b>Output</b> : SyntaxError: Identifier 'a' has already been declared</li>
694+
<li><b>Reason</b> : In Javascript, we cannot redeclare a variable with let if it has already been declared in the same scope. </li>
695+
</ul>
696+
</details>
697+
698+
**[:top: Scroll to Top](#javascript-output-based-interview-questions)**
699+
700+
**40. What will be the output**
701+
```js
702+
const arr = ["A","B","C","D","E"]
703+
console.log(Object.keys(arr));
704+
```
705+
<details>
706+
<summary><b>View Answer</b></summary>
707+
<ul>
708+
<li><b>Output</b> : [ '0', '1', '2', '3', '4' ]</li>
709+
<li><b>Reason</b> : In JavaScript, arrays are a special type of object. Object.keys() on an array returns an array of strings representing the indices of the array elements. </li>
710+
</ul>
711+
</details>
712+
713+
**[:top: Scroll to Top](#javascript-output-based-interview-questions)**
714+

0 commit comments

Comments
 (0)