{"ScriptPreparationCode":"window.target = \u0027tEsT\u0027;\r\nvar data = window.data = [];\r\nconst possible = \u0022ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\u0022;\r\nvar TOTAL_STRINGS = window.TOTAL_STRINGS = 100000;\r\n\r\nfunction getRandomInt(max) {\r\n return Math.floor(Math.random() * max);\r\n}\r\n\r\nfunction makeRandomString(len) {\r\n var text = \u0022\u0022;\r\n for (var i = 0; i \u003C len; i\u002B\u002B) {\r\n text \u002B= possible.charAt(getRandomInt(possible.length));\r\n }\r\n return text;\r\n}\r\n\r\nwhile (data.length \u003C TOTAL_STRINGS) {\r\n data.push(makeRandomString(getRandomInt(20)));\r\n}","TestCases":[{"Name":"Regex outside loop","Code":"var regex = new RegExp(\u0027^\u0027\u002Bwindow.target,\u0027i\u0027);\r\nwindow.data.forEach(str =\u003E regex.test(str));","IsDeferred":false},{"Name":"startsWith()","Code":"window.data.forEach(str =\u003E str.toLowerCase().startsWith(window.target.toLowerCase()));","IsDeferred":false},{"Name":"indexOf()","Code":"window.data.forEach(str =\u003E str.toLowerCase().indexOf(window.target.toLowerCase()) === 0);","IsDeferred":false},{"Name":" localeCompare()","Code":"window.data.forEach(str =\u003E {\r\n str.subStr(0,window.target.length).localeCompare(window.target, undefined, { sensitivity: \u0027base\u0027, usage:\u0027search\u0027});\r\n});","IsDeferred":false},{"Name":"Regex inside loop","Code":"window.data.forEach(str =\u003E {\r\n (new RegExp(\u0027^\u0027\u002Bwindow.target,\u0027i\u0027)).test(str);\r\n});","IsDeferred":false}]}