{"ScriptPreparationCode":"window.data = []\r\nfor (let i = 0; i \u003C 1000; i\u002B\u002B) {\r\n window.data.push({a: Math.floor(Math.random() * 100), b: Math.floor(Math.random() * 100)})\r\n}","TestCases":[{"Name":"Call the same calc function with different arguments","Code":"const { data } = window\r\n\r\nclass DataItem {\r\n a\r\n b\r\n\r\n constructor(a, b, c) {\r\n this.a = a\r\n this.b = b\r\n }\r\n\r\n calc(c) {\r\n return \u0060${this.a} \u002B ${this.b} \u002B ${c} = ${this.a \u002B this.b \u002B c}\u0060\r\n }\r\n}\r\n\r\nconst fnCalls = []\r\n\r\nfor (let c = 0; c \u003C data.length; c\u002B\u002B) {\r\n const { a, b } = data[c]\r\n const dataItem = new DataItem(a, b)\r\n fnCalls.push([dataItem.calc, dataItem, [c]])\r\n}\r\n\r\nfnCalls.forEach(([fn, thisArg, args] = call) =\u003E\r\n console.log(fn.apply(thisArg, args))\r\n)","IsDeferred":false},{"Name":"Call separate closures for each calc","Code":"const { data } = window\r\n\r\nconst fns = []\r\n\r\nfor (let c = 0; c \u003C data.length; c\u002B\u002B) {\r\n const {a, b} = data[c];\r\n const fn = function() {\r\n return \u0060${a} \u002B ${b} \u002B ${c} = ${a \u002B b \u002B c}\u0060\r\n }\r\n fns.push(fn)\r\n}\r\n\r\nfns.forEach(fn =\u003E console.log(fn()))\r\n","IsDeferred":false}]}