Skip to content

Commit de74d81

Browse files
authored
Code formatting and explanation
1 parent 2309a15 commit de74d81

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/shared/md/2010-02-12-foonanny.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1-
Evaluted as foo + (+ bar”), which converts “bar” to not a number.
1+
Evaluted as `"foo" + (+ "bar")`, which converts “bar” to not a number.
22

33
Proposal to rename this site: NaNwtf
44

55
<code>
66
("foo" + + "bar") === "fooNaN" // true
7-
</code>
7+
</code>
8+
9+
**Explanation**
10+
1. `+"bar"` calls `"bar".valueOf()` which tries to return a number
11+
2. Because "bar" is a string, it returns `NaN` instead
12+
3. `"foo"` is concatinated with `NaN`
13+
4. Because of the concatination `NaN.toString()` is called which results in `"foo" + "NaN"`

0 commit comments

Comments
 (0)