{"id":25341172,"url":"https://github.com/vikrantnegi/understanding-javascript-the-weird-parts-notes","last_synced_at":"2026-01-19T08:32:36.820Z","repository":{"id":78928237,"uuid":"132260677","full_name":"vikrantnegi/Understanding-Javascript-The-Weird-Parts-Notes","owner":"vikrantnegi","description":"Notes","archived":false,"fork":false,"pushed_at":"2018-05-05T16:07:46.000Z","size":391,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-14T08:18:37.417Z","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/vikrantnegi.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":"2018-05-05T15:32:48.000Z","updated_at":"2018-05-05T16:07:47.000Z","dependencies_parsed_at":"2023-03-05T00:15:19.052Z","dependency_job_id":null,"html_url":"https://github.com/vikrantnegi/Understanding-Javascript-The-Weird-Parts-Notes","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vikrantnegi%2FUnderstanding-Javascript-The-Weird-Parts-Notes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vikrantnegi%2FUnderstanding-Javascript-The-Weird-Parts-Notes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vikrantnegi%2FUnderstanding-Javascript-The-Weird-Parts-Notes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vikrantnegi%2FUnderstanding-Javascript-The-Weird-Parts-Notes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vikrantnegi","download_url":"https://codeload.github.com/vikrantnegi/Understanding-Javascript-The-Weird-Parts-Notes/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247838449,"owners_count":21004581,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":"2025-02-14T08:18:40.925Z","updated_at":"2026-01-19T08:32:36.780Z","avatar_url":"https://github.com/vikrantnegi.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Understanding Javascript: The Weird Parts\n\n### Functions\n* Are special type of objects\n\n![Function Constructor](./assets/function-constructor.png)\n\n### Function Statement\n```\nfunction greet(name) {\n  console.log(\"hello \" + name);\n}\n```\n\n### Function Expression\n```\nvar greetFunc = function(name) {\n  console.log(\"Hello \" + name);\n}\n```\n* Function is not put into memory initially but during exceution\n* JS engine create the function on the fly as soon it hits the line number\n\n### IIFE - Immediately Invoked Function Expression\n```\n(function(name) {\n  console.log(\"Hello \" + name);\n}());\n```\n* First word of the function statement must be a function\n* Wrapping function statement in a () tricks syntax parser to think it is a function expression and crates the object on the fly and invokes it, all at the same time.\n* Creates its own extecution context so all variables inside it are isolated from outer environment.\n\n### Closures\nWatch Video\n\n### .bind(), .apply(), call()\n### .bind()\nCreates a coy of whatever functions it is called on and object passed to it will be the refrence by\n`this`\n\n\n### Inheritance\nOne object get access to properties and methods of another object.\n\n### Prototype\nAll objects have prototype property.\n\n### Reflection and Extend\nReflection - An object can look ay itself, listening and changing its properties and methods.\n\n### Function Constructors\n* A normal function that is used to construct objects.\n* The this variable points a new empty object, and that object is returned from the function automatically.\n\n```\nfunction Person(firstname, lastname) {\n  console.log(this);\n  this.firstname = firstname;\n  this.lastname = lastname;\n  console.log('This function is invoked.');\n}\n\nvar john = new Person('John', 'Doe');\nconsole.log(john);\n\nvar jane = new Person('Jane', 'Doe');\nconsole.log(jane);\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvikrantnegi%2Funderstanding-javascript-the-weird-parts-notes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvikrantnegi%2Funderstanding-javascript-the-weird-parts-notes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvikrantnegi%2Funderstanding-javascript-the-weird-parts-notes/lists"}