From bcff7fc1d4d425b5146f315df2bd337dd09c52c2 Mon Sep 17 00:00:00 2001 From: pearmini Date: Fri, 26 Sep 2025 08:10:10 -0400 Subject: [PATCH] Add wftjs --- app/examples/wtfjs.recho.js | 69 +++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 app/examples/wtfjs.recho.js diff --git a/app/examples/wtfjs.recho.js b/app/examples/wtfjs.recho.js new file mode 100644 index 0000000..d682dff --- /dev/null +++ b/app/examples/wtfjs.recho.js @@ -0,0 +1,69 @@ +/** + * @title What the f*ck JavaScript? + * @author Bairui Su + * @created 2025-09-25 + * @pull_request 123 + * @github pearmini + * @thumbnail_start 26 + */ + +/** + * ============================================================================ + * = What the f*ck JavaScript? = + * ============================================================================ + * + * JavaScript is a powerful language, flexible syntax and a large ecosystem + * with a great community. However, it also has some quirks and unexpected + * behaviors that can be dangerous but funny. + * + * Here are some of the examples from https://github.com/denysdovhan/wtfjs. + */ + +//➜ true +echo([] == ![]); +// https://github.com/denysdovhan/wtfjs?tab=readme-ov-file#-is-equal- + +//➜ false +echo(0.1 + 0.2 === 0.3); +// https://github.com/denysdovhan/wtfjs?tab=readme-ov-file#precision-of-01--02 + +//➜ "baNaNa" +echo("b" + "a" + +"a" + "a"); +// https://github.com/denysdovhan/wtfjs?tab=readme-ov-file#banana + +//➜ "fail" +echo( + (![] + [])[+[]] + + (![] + [])[+!+[]] + + ([![]] + [][[]])[+!+[] + [+[]]] + + (![] + [])[!+[] + !+[]] +) +// https://github.com/denysdovhan/wtfjs?tab=readme-ov-file#its-a-fail + +//➜ 15 +echo(parseInt("f*ck", 16)); +// https://github.com/denysdovhan/wtfjs?tab=readme-ov-file#parseint-is-a-bad-guy + +//➜ "1,2,34,5,6" +echo([1, 2, 3] + [4, 5, 6]); +// https://github.com/denysdovhan/wtfjs?tab=readme-ov-file#adding-arrays + +//➜ "first" +foo: { + echo("first"); + break foo; + echo("second"); +} +// https://github.com/denysdovhan/wtfjs?tab=readme-ov-file#labels + +//➜ 1 +//➜ 2 +//➜ 3 +//➜ 4 +//➜ 5 +a: b: c: d: e: f: g: echo(1), echo(2), echo(3), echo(4), echo(5); +// https://github.com/denysdovhan/wtfjs?tab=readme-ov-file#labels + +//➜ [ 1, 10, 3 ] +echo([10, 1, 3].sort()); +// https://github.com/denysdovhan/wtfjs?tab=readme-ov-file#default-behavior-arrayprototypesort