Skip to content

Commit

Permalink
feat: Add A stringified string example. Close #113
Browse files Browse the repository at this point in the history
  • Loading branch information
denysdovhan committed Feb 6, 2021
1 parent 827da42 commit de081e4
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ Currently, there are these translations of **wtfjs**:
- [Extra Newness](#extra-newness)
- [Why you should use semicolons](#why-you-should-use-semicolons)
- [Split a string by a space](#split-a-string-by-a-space)
- [A stringified string](#a-stringified-string)
- [πŸ“š Other resources](#-other-resources)
- [πŸŽ“ License](#-license)

Expand Down Expand Up @@ -2025,6 +2026,30 @@ Let's quote the specification:
- [An original tween with an example](https://twitter.com/SeaRyanC/status/1331656278104440833) by Ryan Cavanaugh
- [A tween with an explanation](https://twitter.com/kl13nt/status/1331742810932916227?s=20) by Nabil Tharwat

## A stringified string

This caused a bug that I've been solving for a few days:

```js
JSON.stringify('production') === 'production' // -> false
```

### πŸ’‘ Explanation:

Let's see what `JSON.stringify` is returning:

```js
JSON.stringify('production') // -> '"production"'
```

It is actually a stringified string, so it's true:

```js
'"production"' === 'production' // -> false
```

- [ECMA-404 The JSON Data Interchange Standard.](https://www.json.org/json-en.html)

# πŸ“š Other resources

- [wtfjs.com](http://wtfjs.com/) β€” a collection of those very special irregularities, inconsistencies and just plain painfully unintuitive moments for the language of the web.
Expand Down

0 comments on commit de081e4

Please sign in to comment.