{"ScriptPreparationCode":"var voucher = {\r\n \u0022single\u0022: false,\r\n \u0022applyOverTaxes\u0022: false,\r\n \u0022discountType\u0022: \u00221\u0022,\r\n \u0022value\u0022: 100,\r\n \u0022minimumAmount\u0022: 0,\r\n \u0022quantity\u0022: 1,\r\n \u0022suffixLength\u0022: 8,\r\n \u0022code\u0022: \u0022IF5R0AFX\u0022,\r\n \u0022vertical\u0022: true,\r\n \u0022allowedPaymentMethods\u0022: null,\r\n \u0022allowedBanks\u0022: null,\r\n \u0022types\u0022: undefined,\r\n \u0022partners\u0022: \u0022Many\u0022,\r\n \u0022startDate\u0022: \u00222020-10-21T00:00:00.000Z\u0022,\r\n \u0022endDate\u0022: \u00222020-10-21T00:00:00.000Z\u0022,\r\n \u0022applyed\u0022: false\r\n}\r\n\r\nfunction copy(toCopy)\r\n{\r\n\tif(typeof toCopy !== \u0027object\u0027 || toCopy === null)\r\n\t{\r\n\t\treturn toCopy;\r\n\t}\r\n\telse if(Array.isArray(toCopy))\r\n\t{\r\n\t\tlet len = toCopy.length;\r\n\t\tlet result = new Array(len);\r\n\r\n\t\tfor(let i = 0; i \u003C len; i\u002B\u002B)\r\n\t\t{\r\n\t\t\tlet _toCopy = toCopy[i];\r\n\t\t\tresult[i] = typeof _toCopy !== \u0027object\u0027 || _toCopy === null ? _toCopy : copy(_toCopy);\r\n\t\t}\r\n\r\n\t\treturn result;\r\n\t}\r\n\telse\r\n\t{\r\n\t\tlet result = {};\r\n\r\n\t\tfor(let i in toCopy)\r\n\t\t{\r\n\t\t\tlet _toCopy = toCopy[i];\r\n\t\t\tresult[i] = typeof _toCopy !== \u0027object\u0027 || _toCopy === null ? _toCopy : copy(_toCopy);\r\n\t\t}\r\n\r\n\t\treturn result;\r\n\t}\r\n}","TestCases":[{"Name":"structuredClone()","Code":"var newObj = structuredClone(voucher)","IsDeferred":false},{"Name":"spread syntax","Code":"var newObj = {...voucher}","IsDeferred":false},{"Name":"Object.assign","Code":"var newObj = Object.assign({}, voucher)","IsDeferred":false},{"Name":"Object.fromEntries","Code":"var newObj = Object.fromEntries(Object.entries(voucher))","IsDeferred":false},{"Name":"JSON","Code":"// loses the \u0022types\u0022 property\r\nvar newObj = JSON.parse(JSON.stringify(voucher))","IsDeferred":false},{"Name":"Cursed Proxy","Code":"// this registers as surprisingly performant for some reason, but keep in mind i didn\u0027t benchmark\r\n// usage, only creation, so in reality this could potentially not be performant when setting/getting.\r\n// either way this is really scuffed so you probably shouldn\u0027t take this approach\r\nvar newObject = new Proxy({}, {\r\n get (o, p) { return p in o ? o[p] : o[p] ??= voucher[p] },\r\n set (o, p, v) { o[p] = v; return true }\r\n})","IsDeferred":false},{"Name":"Copy","Code":"var newObj = copy(voucher)","IsDeferred":false}]}