{"ScriptPreparationCode":"var map = {};\r\n\r\nfunction generateSequence(prefix, numItems) { \r\n var buffer = [];\r\n var prefixInstance = prefix || \u0022\u0022;\r\n for (var i = 0; i \u003C numItems; i\u002B\u002B) {\r\n buffer.push(prefix \u002B i);\r\n }\r\n return buffer;\r\n}\r\n\r\nvar startTime;\r\nfunction startTimer() {\r\n startTime = new Date().getTime()\r\n}\r\nfunction stopTimer() {\r\n var endTime = new Date().getTime();\r\n console.log(\u0022Took \u0022 \u002B (endTime - startTime) \u002B \u0022 ms\u0022);\r\n}\r\n\r\nfunction generateMap() {\r\n console.log(\u0022Generating\u0022);\r\n for (var i = 0; i \u003C 50000; i\u002B\u002B) {\r\n\tmap[\u0022a-\u0022 \u002B i] = { \r\n a: generateSequence(\u0022aaaaaaaaa\u0022, 10)\r\n }\r\n }\r\n\r\n}\r\n","TestCases":[{"Name":"The slow version","Code":"generateMap();\r\nconsole.log(\u0022Test #1\u0022);\r\nstartTimer();\r\nfor (key in map) {\r\n if (map.hasOwnProperty(key)) { \r\n delete map[key];\r\n }\r\n}\r\nstopTimer();","IsDeferred":false},{"Name":"Faster version using Object.keys().","Code":"generateMap();\r\nconsole.log(\u0022Test #2\u0022);\r\nstartTimer();\r\nvar keys = Object.keys(map);\r\nfor (var i = 0, ii = keys.length; i \u003C ii; i\u002B\u002B) {\r\n delete map[keys[i]];\r\n}\r\nstopTimer();","IsDeferred":false}]}