{"id":23437049,"url":"https://github.com/vivekimsit/til","last_synced_at":"2026-01-22T02:03:15.867Z","repository":{"id":147362111,"uuid":"83988794","full_name":"vivekimsit/til","owner":"vivekimsit","description":"Lets learn something everyday.","archived":false,"fork":false,"pushed_at":"2018-11-24T20:19:49.000Z","size":57,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-09T18:54:29.462Z","etag":null,"topics":["knowledgebase","motivation","today-i-learned"],"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/vivekimsit.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":"2017-03-05T17:30:23.000Z","updated_at":"2025-04-09T16:29:44.000Z","dependencies_parsed_at":"2023-04-17T01:48:29.186Z","dependency_job_id":null,"html_url":"https://github.com/vivekimsit/til","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/vivekimsit/til","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vivekimsit%2Ftil","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vivekimsit%2Ftil/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vivekimsit%2Ftil/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vivekimsit%2Ftil/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vivekimsit","download_url":"https://codeload.github.com/vivekimsit/til/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vivekimsit%2Ftil/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28650594,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-22T01:17:37.254Z","status":"online","status_checked_at":"2026-01-22T02:00:07.137Z","response_time":144,"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":["knowledgebase","motivation","today-i-learned"],"created_at":"2024-12-23T13:37:45.302Z","updated_at":"2026-01-22T02:03:15.862Z","avatar_url":"https://github.com/vivekimsit.png","language":null,"readme":"# TIL\n\n\u003e Lets learn something everyday.\n\n#### Map\n\n```\n var m = {};\n var a = {id: 1},\n     b = {id: 2};\n m[x] = 'foo';\n m[x] = 'bar';\n \n m[x]?\n m[y]?\n```\n\n#### WeakMap\n\n1. WeakMap take only object as keys.\n2. They don't have `size` or `clear` method.\n3. They don't have iterartor over `keys`, `values` or `entries`.\n\n#### Array\n\nInitialize an array of given length with default values:\n\n```\nArray(3).fill(null); // [null, null, null]\n```\n\n#### Destructuring\n\n```\n// Fail-soft destructuring with defaults\nvar [a = 1] = [];\na === 1;\n```\n\n#### Classes\n\nUnlike function declarations, class declarations are not hoisted.\n\n```js\n\n// A class only exists after execution reached its definition and it was evaluated.\n// Accessing it beforehand leads to a ReferenceError\n\nnew Foo();\n\nclass Foo {}\n\n```\n\n#### Null\n\n```js\nvar a = null;\n\n(!a \u0026\u0026 typeof a === \"object\"); // true\n```\n\nnull is the only primitive value that is \"falsy\" but that also returns \"object\"\nfrom the typeof check.\n\n#### Reference error\n\nUnlike referencing undeclared variables, there is no ReferenceError thrown if\nyou try to access an object property (even on the global window object) that\ndoesn't exist.\n\n#### A class body can only contain methods, but not data properties.\n\n\nPrototypes having data properties is generally considered an anti-pattern, so this just enforces a best practice.\n\n`constructor, static methods, prototype methods`\n\n#### Rest vs Spread\n\nspread elements 'expands' an array into its elements, and rest elements collects\nmultiple elements and 'condenses' into a single element.\n\n[source (mdn)](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Operators/Spread_operator)\n\n#### Instance methods and properties\n\n```js\n\n class Bork {\n    //Property initializer syntax\n    instanceProperty = \"bork\";\n    boundFunction = () =\u003e {\n      return this.instanceProperty;\n    }\n\n    //Static class properties\n    static staticProperty = \"babelIsCool\";\n    static staticFunction = function() {\n      return Bork.staticProperty;\n    }\n  }\n```\n[Babel plugin](https://babeljs.io/docs/plugins/transform-class-properties/)\n\n### Function default values\n\n```js\nfunction foo(opts) {\n  opts = Object.assign({\n    pow: ''\n  }, opts);\n}\n```\n\n## Web performance\n\n[Faster Font Loading with Font Events](https://jonsuh.com/blog/font-loading-with-font-events/)\n\n\n### Reducers\n\nUsing combineReducers does \"call all reducers\", or at least all of the slice reducers it is wrapping.\n\n[Link](https://github.com/markerikson/redux/blob/structuring-reducers-page/docs/recipes/reducers/04-UsingCombineReducers.md)\n\n### VIM\n\n#### Convert tabs to spaces in a file\n\nSelect visually the area to apply the changes then,\n\n`:retab`\n\n### Service workers\n\nA service worker is run in a worker context: it therefore has *no DOM access*,\nand *runs on a different thread* to the main JavaScript that powers your app,\nso it is not blocking. It is designed to be *fully async*; as a consequence,\nAPIs such as synchronous XHR and localStorage can't be used inside a service worker.\n\n#### Javascript\n\nStatements:\n\n1. Declaration Statement `var a = 5`\n2. Assignment Statement `b = a`\n3. Expression statement `a`\n\nAll statements have **completion values** event if its `undefined`.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvivekimsit%2Ftil","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvivekimsit%2Ftil","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvivekimsit%2Ftil/lists"}