{"id":13847459,"url":"https://github.com/themithy/the-insane-javascript-interview","last_synced_at":"2025-07-12T09:32:04.366Z","repository":{"id":116240864,"uuid":"223638536","full_name":"themithy/the-insane-javascript-interview","owner":"themithy","description":"Hardest JavaScript questions that I could think of","archived":false,"fork":false,"pushed_at":"2023-01-24T19:32:07.000Z","size":30,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-08-05T18:23:48.266Z","etag":null,"topics":["javascript"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/themithy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2019-11-23T18:59:19.000Z","updated_at":"2023-11-16T08:38:45.000Z","dependencies_parsed_at":"2024-01-15T20:51:34.199Z","dependency_job_id":"364a2c6d-6d43-4980-b2f1-5ae3638ac328","html_url":"https://github.com/themithy/the-insane-javascript-interview","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/themithy%2Fthe-insane-javascript-interview","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/themithy%2Fthe-insane-javascript-interview/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/themithy%2Fthe-insane-javascript-interview/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/themithy%2Fthe-insane-javascript-interview/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/themithy","download_url":"https://codeload.github.com/themithy/the-insane-javascript-interview/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225812900,"owners_count":17528083,"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":["javascript"],"created_at":"2024-08-04T18:01:26.988Z","updated_at":"2024-11-21T22:30:21.823Z","avatar_url":"https://github.com/themithy.png","language":null,"funding_links":[],"categories":["Others"],"sub_categories":[],"readme":"# Insane JavaScript interview\n\nThis is a compilation of hardest JavaScript questions that I could think\nof. The difficulty level is beyond the level of sanity and even skilled\nprogrammers should never be bothered with such language features.  But if you\nare interested in the less-known parts of the spec - give it a try!\n\n1. What would be the result of the following expression ?\n\n```js\nconsole.log(!'0' == '0') // ?\n```\n\n2. What would be the result of running the following code ?\n\n```js\nundefined = null // ?\n```\n\n3. What would be the result of running the following code ?\n\n```js\nvar a = 1\n\n{\n  let a = a + 1\n  console.log(a) // ?\n}\n```\n\n4. How to reliably check whether a variable is an object ?\n\n5. What would be the result of running the following code ?\n\n```js\nfunction func() {\n  console.log(Array.isArray(arguments)) // ?\n}\n\nfunc(1, 2)\n```\n\n6. How to detect whether a function has been called as a constructor ?\n\n7. What would be the result of running the following two lines of code ?\n\n```js\nvar a = new One() // ?\nvar b = new Two() // ?\n\nfunction One() {} \n\nclass Two {}\n```\n\n8. What would be the result of running the following code ?\n\n```js\nvar a = {}\nvar b = {}\n\nObject.setPrototypeOf(a, b)\nObject.setPrototypeOf(b, a)\n```\n\n9. What would be the result of the following expression ?\n\n```js\ntypeof [] instanceof Array\n```\n\n10. What would be the result of the following expression ?\n\n```js\n1000 == 01750n\n```\n\n11. What would be the result of the following expression ?\n\n```js\nconsole.log(2**53 == 2**53 + 1) // ?\n```\n\n12. What would be the result of running the following code ?\n\n```js\nconst obj = {}\n\nobj[undefined] = 1\nobj[false] = 2\nobj[+0] = 3\nobj[-0] = 4\nobj['0'] = 5\nobj[{}] = 6\n\nconsole.log(Object.values(obj)) // ?\n```\n\n13. What would be the result of running the following code ?\n\n```js\nconst Func = () =\u003e {}\n\nconst val = new Func() // ?\n```\n\n14. What would be the result of running the following code ?\n\n```js\nfunction Tree() {}\n\nconst tree = new Tree()\n\nconsole.log(tree.constructor.prototype.__proto__.__proto__) // ?\n```\n\n15. What would be the result of running the following code ?\n\n```js\nconst target = new Number(5)\nconst proxy = new Proxy(target, {})\n\nconsole.log(proxy.toString()) // ?\n```\n\n16. What is the difference between `Object.preventExtensions`, `Object.seal`\n    and `Object.freeze` ?\n\n17. What would be the result of running the following code ?\n\n```js\nfunction a() {\n  const x = arguments[0]\n\n  const b = () =\u003e {\n    const y = arguments[0]\n    console.log(y) // ?\n  }\n\n  b(2 * x)\n}\n\na(10)\n```\n\n18. What would be the result of running the following code ?\n\n```js\nconst key = Symbol('abc')\n\nconst obj = { [key]: 'def' }\n\nconsole.log(JSON.stringify(obj)) // ?\n```\n\n19. What would be the result of the following expression ?\n\n```js\nfalse.__proto__\n```\n\n20. What would be the result of the following expression ?\n\n```js\ntypeof /abc/\n```\n\n21. What is the difference between `Object.keys` and\n    `Object.getOwnPropertyNames` ?\n\n22. What would be the result of running the following code ?\n\n```js\nfunction a() {}\nconst b = () =\u003e {}\n\na.__proto__ == b.__proto__ // ?\n```\n\n23. What would be the result of running the following code ?\n\n```js\nPromise.resolve()\n  .then(() =\u003e Promise.resolve('abc'))\n  .then((val) =\u003e {\n    console.log(typeof val) // ?\n  })\n```\n\n24. What would be the result of the following expression ?\n\n```js\n1 + - 0 || new 0\n```\n\n25. What would be the result of running the following code ?\n\n```js\nasync function print(val) {\n  console.log(val)\n}\n\nasync function run() {\n  [1, 2, 3].forEach(async (val) =\u003e {\n    await print('A' + val)\n    print('B' + val)\n  })\n}\n\nrun()\n```\n\n26. What would be the result of the following expression ?\n\n```js\nSymbol('1') + '2'\n```\n\n27. What would be the result of running the following code ?\n\n```js\nvar a = b, b = 1\n\nconsole.log('a: ' + a) // ?\nconsole.log('b: ' + b) // ?\n```\n\n28. What would be the result of running the following code ?\n\n```js\nvar prop = 1\n\ndelete prop // ?\n```\n\n29. What would be the result of the following expression ?\n\n```js\nnull == false\n```\n\n30. What would be the result of running the following code ?\n\n```js\nconst a = new Date()\nconst b = Object.assign(Object.create(Date.prototype), a)\n\na.toString() == b.toString() // ?\n```\n\n31. What would be the result of running the following code ?\n\n```js\nconst obj = {}\nconst arr = []\n\nobj[5] = true\narr[5] = true\n\nobj['5'] // ?\narr['5'] // ?\n```\n\n32. What would be the result of running the following code ?\n\n```js\nconst arr = [ 1, 2, 3 ]\narr[7.5] = true\n\narr.length = 0\n\nObject.getOwnPropertyNames(arr) // ?\n```\n\n33. What would be the result of running the following code ?\n\n```js\nfunction func() {\n  this.prop = 2\n  return { prop: 4 }\n}\n\nfunc.prototype.prop = 6\n\nconst obj = new func()\n\nobj.prop // ?\n```\n\n34. What would be the result of running the following code ?\n\n```js\nconst arr = []\nObject.setPrototypeOf(arr, Object.prototype)\n\narr instanceof Array // ?\n```\n\n35. What would be the result of running the following code ?\n\n```js\n[ 0, 2, 4 ].flatMap((x) =\u003e [ x, x + 1 ])\n```\n\n36. What would be the result of the following expression ?\n\n```js\nnew Int8Array instanceof Array\n```\n\n37. What would be the result of running the following code ?\n\n```js\nlet i = 0\n\nfor (; i \u003c 10; i++) {\n  setTimeout(() =\u003e console.log('i=' + i))\n}\n```\n\n38. What would be the result of running the following code ?\n\n```js\nconst obj = { a: true }\n\nfor (const v of obj) {\n  console.log(v)\n}\n```\n\n39. What would be the result of running the following code ?\n\n```js\nconst arr = []\nconst it = arr[Symbol.iterator]()\n\nit.next() // ?\n```\n\n40.  What would be the result of running the following code ?\n\n```js\nconst map = new Map()\n\nmap['a'] = true\nmap.set('b', true)\n\nmap.get('a') // ?\nmap['b'] // ?\n```\n\n41.  What would be the result of running the following code ?\n\n```js\nconst arr = [1, 2, 3]\n\nfor (const a of arr) {\n  if (a \u003c= 3) {\n    arr.push(a + 3)\n  }\n  console.log(a)\n}\n```\n\n42.  What would be the result of running the following code ?\n\n```js\nconst obj = {}\n\nObject.defineProperty(obj, 'a', {})\nObject.defineProperty(obj, 'b', { get: () =\u003e {} })\nObject.defineProperty(obj, 'c', { set: () =\u003e {} })\n\nObject.getOwnPropertyNames(obj) // ?\n```\n\n43. What would be the result of the following expression ?\n\n```js\nNaN ** 0\n```\n\n44. What would be the result of the following expression ?\n\n```js\nJSON.parse('{}').__proto__\n```\n\n45. What would be the result of running the following code ?\n\n```js\nfunction Func() {\n  return new this.constructor()\n}\n\nnew Func()\n```\n\n46. What would be the result of the following expressions ?\n\n```js\n// 1.\ntrue + true // ?\n\n// 2.\ntrue + 1 // ?\n\n// 3.\ntrue + '1' // ?\n```\n\n47. What is the difference between `Function.prototype.call` and\n    `Function.prototype.apply` ?\n\n48. What is the purpose of function `Reflect.construct` ?\n\n49. What is the difference between `Object.preventExtensions` and\n    `Reflect.preventExtensions` ?\n\nFinal one. Why are all those questions so difficult ?\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthemithy%2Fthe-insane-javascript-interview","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthemithy%2Fthe-insane-javascript-interview","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthemithy%2Fthe-insane-javascript-interview/lists"}