Skip to content

Commit a21c001

Browse files
committed
why-does-return-the-string-10?rq=1
1 parent 0b20b9c commit a21c001

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

Javascript/Tricky-JS-Problems/Collection-of-Tricky-JS-Questlions.md

+17
Original file line numberDiff line numberDiff line change
@@ -249,3 +249,20 @@ Question: What is `2 in [1,2]`
249249
**Answer:** false. Because "in" returns whether a particular property/index available in the Object. In this case object has index 0 and 1 but don't have 2. Hence you get false.
250250

251251
---
252+
253+
### Question - Why does ++[[]][+[]]+[+[]] return the string “10”?
254+
255+
**Answer** -
256+
257+
```js
258+
++[[]][+[]] => 1 // [+[]] = [0], ++0 = 1
259+
[+[]] => [0]
260+
```
261+
262+
Then we have a string concatenation
263+
264+
```js
265+
1 + [0].toString() = 10
266+
```
267+
268+
**For Detailed Ans - see **

0 commit comments

Comments
 (0)