{"id":21906122,"url":"https://github.com/evermake/iljs","last_synced_at":"2026-02-12T02:40:26.432Z","repository":{"id":241804792,"uuid":"807678605","full_name":"evermake/iljs","owner":"evermake","description":"I Love JavaScript 💛","archived":false,"fork":false,"pushed_at":"2025-02-16T10:23:51.000Z","size":5,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-08T02:04:37.938Z","etag":null,"topics":["javascript"],"latest_commit_sha":null,"homepage":"","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/evermake.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-29T15:05:17.000Z","updated_at":"2025-02-16T10:35:13.000Z","dependencies_parsed_at":null,"dependency_job_id":"6703af39-2624-4c70-9e34-8afabf8b0096","html_url":"https://github.com/evermake/iljs","commit_stats":null,"previous_names":["evermake/iljs"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/evermake/iljs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evermake%2Filjs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evermake%2Filjs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evermake%2Filjs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evermake%2Filjs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/evermake","download_url":"https://codeload.github.com/evermake/iljs/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evermake%2Filjs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29355264,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-12T01:03:07.613Z","status":"online","status_checked_at":"2026-02-12T02:00:06.911Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["javascript"],"created_at":"2024-11-28T16:41:24.470Z","updated_at":"2026-02-12T02:40:26.417Z","avatar_url":"https://github.com/evermake.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"### subjective `null`\n\n```js\n{} instanceof null\n// Uncaught TypeError: Right-hand side of 'instanceof' is not an object\n```\n\n```js\ntypeof null\n// 'object'\n```\n\n**[Explanation](https://stackoverflow.com/a/7968470)**\n\n`null` is not an object, but a primitive value. `typeof null` returning `'object'` is a bug, which is not fixed due to backward-compatability.\n\n---\n\n### '2' + '2' - '2' = 20\n\n```js\n'2' + '2' - '2'\n// 20\n```\n\n**[Explanation](https://stackoverflow.com/a/48675918)**\n\n- `+` is both concatenation and addition (`'2' + '2'` is `'22'`);\n- `-` is only subtraction and arguments are coerced to numbers (`'22' - 2` is `20`).\n\n---\n\n### `typeof` undeclared\n\n```js\nconsole.log(abc)\n// Uncaught ReferenceError: abc is not defined\n```\n\n```js\nconsole.log(typeof abc)\n// 'undefined'\n```\n\n**Explanation**\n\n`typeof` operator can check whether the variable has been declared.\n\n---\n\n### [sparse arrays](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Indexed_collections#sparse_arrays)\n\n```js\nconsole.log(Array(5))\n// [ \u003c5 empty items\u003e ]\n\nconst arr = [1,,,2,,,3]\n\nconsole.log(arr.length)\n// 7\n\narr.forEach((item, idx) =\u003e console.log(item, idx))\n// 1 0\n// 2 3\n// 3 6\n\nconsole.log(JSON.stringify(arr))\n// '[1,null,null,2,null,null,3]'\n\nconst arr2 = [...arr]\narr2.forEach((item, idx) =\u003e console.log(item, idx))\n// 1 0\n// undefined 1\n// undefined 2\n// 2 3\n// undefined 4\n// undefined 5\n// 3 6\n\narr[1000] = 1\n\nconsole.log(arr.length)\n// 1001\n\nconsole.log(arr)\n// [ 1, \u003c2 empty items\u003e, 2, \u003c2 empty items\u003e, 3, \u003c993 empty items\u003e, 1 ]\n```\n\n\u003cdetails\u003e\n\u003csummary\u003eStory\u003c/summary\u003e\n\nSomeday I was writing a Telegram bot and spent several hours debugging one issue.\n\nBot had logging functionality and logged something `JSON.stringif`ied, and after some changes I got an error:\n\n```\nFATAL ERROR: JS Allocation failed - process out of memory\n```\n\nIn short, the problem was that I was setting some array's item by _Telegram user's ID_ (which was big like 987654321). So JS tried to stringify an array with nine hundred eighty-seven million six hundred fifty-four thousand three hundred twenty-one `null` and ran out of memory:\n\n```js\narr[user.id] = 'hi'\nJSON.stringify(arr)\n// FATAL ERROR: JS Allocation failed - process out of memory\n```\n\n\u003c/details\u003e\n\n---\n\n### `parseInt`\n\n```js\nparseInt(0.5)\n// 0\n\nparseInt(0.005)\n// 0\n\nparseInt(0.0000005)\n// 5\n```\n\n**Explanation**\n\n- The `parseInt` function _converts its first argument to a string_, parses that string, then returns an integer or `NaN`.\n- If `parseInt` encounters a character that is not a numeral in the specified `radix`, it _ignores it and all succeeding characters_ and returns the integer value parsed up to that point.\n- `(0.5).toString()` -\u003e `'0.5'`\n- `(0.0000005).toString()` -\u003e `'5e-7'`\n\n---\n\n### `018 === 022`\n\n```js\n018 === 022\n// true\n```\n\n**Explanation**\n\n- A leading `0` on an integer literal, or a leading `0o` (or `0O`) indicates it is in octal. Octal integer literals can include only the digits `0` – `7`. ([MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Grammar_and_types#numeric_literals))\n- `022` starts with `0` =\u003e it's in octal\n- `018` contains `8` =\u003e it's not in octal, but in decimal\n- `22` in octal = `18` in decimal\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevermake%2Filjs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fevermake%2Filjs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevermake%2Filjs/lists"}