From de081e4aafe6bc4ca1df47389ac0c3e8b0dff9d1 Mon Sep 17 00:00:00 2001 From: Denys Dovhan Date: Sat, 6 Feb 2021 22:04:08 +0200 Subject: [PATCH] feat: Add A stringified string example. Close #113 --- README.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/README.md b/README.md index e4a10f44..9ef615e6 100644 --- a/README.md +++ b/README.md @@ -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) @@ -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.