{"id":18803580,"url":"https://github.com/rofrol/javascript-wtf-koans","last_synced_at":"2026-01-26T01:32:52.145Z","repository":{"id":35683182,"uuid":"39959276","full_name":"rofrol/javascript-wtf-koans","owner":"rofrol","description":null,"archived":false,"fork":false,"pushed_at":"2016-01-11T22:50:20.000Z","size":4,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-09-29T16:02:59.616Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rofrol.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-07-30T15:58:38.000Z","updated_at":"2016-01-11T22:37:36.000Z","dependencies_parsed_at":"2022-09-04T03:02:36.033Z","dependency_job_id":null,"html_url":"https://github.com/rofrol/javascript-wtf-koans","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/rofrol/javascript-wtf-koans","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rofrol%2Fjavascript-wtf-koans","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rofrol%2Fjavascript-wtf-koans/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rofrol%2Fjavascript-wtf-koans/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rofrol%2Fjavascript-wtf-koans/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rofrol","download_url":"https://codeload.github.com/rofrol/javascript-wtf-koans/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rofrol%2Fjavascript-wtf-koans/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28763942,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-26T00:37:26.264Z","status":"ssl_error","status_checked_at":"2026-01-26T00:37:25.959Z","response_time":113,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-07T22:36:06.495Z","updated_at":"2026-01-26T01:32:52.124Z","avatar_url":"https://github.com/rofrol.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Quotes\r\n\r\n\u003e Writing Javascript is like trying to make up with a pissed off girl.\r\n\u003e You try something, doing your best, and ask \"Everything ok?\"\r\n\u003e Girl/Javascript: \"Fine.\"\r\n\u003e And then you just have to hope \"Fine\" means fine and not \"I'mma cut you while you sleep\".\r\n\u003e -- \u003ccite\u003eKillaCoder\u003c/cite\u003e https://what.thedailywtf.com/t/javascript-gotchas-thread/2671/66\r\n\r\n\u003c!-- --\u003e\r\n\u003e You always run into problems when you design language features around the assumption that your users will mostly be idiots\r\n\u003e -- \u003ccite\u003eRob Van Dam\u003c/cite\u003e http://stackoverflow.com/questions/1995113/strangest-language-feature#comment1924259_2003277\r\n\r\n# WTF links\r\n\r\n- http://stackoverflow.com/questions/1995113/strangest-language-feature\r\n- https://github.com/brianleroux/wtfjs/tree/master/posts\r\n- http://www.smashingmagazine.com/2011/05/10-oddities-and-secrets-about-javascript/\r\n- http://www.evotech.net/blog/2008/10/13-javascript-gotchas/#null\r\n- http://www.codeproject.com/Articles/182416/A-Collection-of-JavaScript-Gotchas\r\n- http://tech.domain.com.au/2015/07/type-coercion-in-javascript/\r\n- https://what.thedailywtf.com/t/javascript-gotchas-thread/2671/65\r\n- http://martin-thoma.com/javascript-wtf/\r\n- (The Strict Equality Comparison Algorithm)[http://ecma-international.org/ecma-262/5.1/#sec-11.9.6]\r\n- https://www.destroyallsoftware.com/talks/wat\r\n- http://davidwalsh.name/fixing-coercion\r\n- https://www.safaribooksonline.com/library/view/you-dont-know/9781491905159/ch04.html\r\n- http://www.2ality.com/2013/04/12quirks.html\r\n- http://cwestblog.com/2014/02/25/javascript-testing-for-negative-zero/\r\n- https://wiki.theory.org/YourLanguageSucks#JavaScript_sucks_because\r\n- `{} + \"wtf\"` `console.log(eval('{}+\"wtf\"'))` https://www.reddit.com/r/javascript/comments/3z74ok/will_let_eventually_replace_var/cyk8vjq\r\n\r\n# How to defend yourself\r\n\r\n- http://eslint.org/docs/1.0.0/rules/no-implicit-coercion.html\r\n- https://github.com/airbnb/javascript\r\n- http://stackoverflow.com/questions/27595749/douglas-crockford-on-class-free-oop-in-javascript\r\n- http://www.breck-mckye.com/blog/2014/05/why-i-prefer-parasitic-inheritance/\r\n- (Douglas Crockford: The Better Parts - JSConfUY 2014)[https://www.youtube.com/watch?v=bo36MrBfTk4]\r\n- (Nordic.js 2014 • Douglas Crockford - The Better Parts)[https://www.youtube.com/watch?v=PSGEjv3Tqo0]\r\n- https://www.udemy.com/the-best-parts-of-javascript-functions-to-error-free-code/\r\n- http://www.amazon.com/JavaScript-The-Good-Parts-ebook/dp/B0026OR2ZY/\r\n- http://stackoverflow.com/questions/18922197/using-parasitic-inheritance-in-javascript-is-it-possible-to-implement-introspec\r\n- http://www.crockford.com/javascript/inheritance.html\r\n- http://blog.chewxy.com/2014/02/24/what-every-javascript-developer-should-know-about-floating-point-numbers/\r\n\r\n# Is Crkockford wrong on DEC64?\r\n\r\n- https://www.reddit.com/r/programming/comments/28r8xt/dec64_is_intended_to_be_the_only_number_type_in/\r\n- https://news.ycombinator.com/item?id=7365812\r\n\r\n## Examples\r\n\r\n### Some WTF moments in Javascript, courtesy of Gary Bernhardt\r\n\r\n```javascript\r\nvar foo = [\"10\", \"10\", \"10\"];\r\nfoo.map(parseInt);\r\n// Returns [ 10, NaN, 2 ]\r\n\r\n[] + [] // \"\"\r\n[] + {} // {}\r\n{} + [] // 0\r\n{} + {} // NaN\r\n\r\nvar a = {};\r\na[[]] = 2;\r\nalert(a[\"\"]); // alerts 2\r\n\r\nalert(Array(16).join(\"wat\" - 1) + \" Batman!\");\r\n```\r\n\r\nhttps://news.ycombinator.com/item?id=8850540\r\n\r\n### Contrived usage of comma operator and behaviour of parseInt - what's the output?\r\n\r\n```javascript\r\nparseInt((null, {test: 99}, false, 'J,uhuru', /asdf/, function() {  giantInflatableShark(!!'!!'); },\r\n     'A,spock', '0') + ('cheese' / 'toast', new Date(), Number('hello'),\r\n     'x') + (undefined, [1, 2, 3], new Array(5), 1e4, 'F,captainkirk'))\r\n```\r\nhttps://gist.github.com/insin/1183916\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frofrol%2Fjavascript-wtf-koans","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frofrol%2Fjavascript-wtf-koans","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frofrol%2Fjavascript-wtf-koans/lists"}