{"ScriptPreparationCode":"var state = {\r\n wrapped1: {\r\n wrapped2: {\r\n location: {\r\n \tsearch: \u0027\u0027,\r\n \tid: 12\r\n }\r\n }\r\n },\r\n data: {}\r\n};\r\n\r\nvar safeGet = function(nestedObj, paths, defaultVal) {\r\n if (!paths || paths.length === 0) return defaultVal\r\n const result = paths.slice(0).reduce((obj, path, i, arr) =\u003E {\r\n if (!obj) {\r\n arr.splice(i) // break out of the loop\r\n return undefined\r\n }\r\n return obj[path]\r\n }, nestedObj)\r\n\r\n if (result === undefined || result === null) {\r\n return defaultVal\r\n }\r\n\r\n return result\r\n}\r\n\r\nvar dlv = function(obj, key, def, p, undef) {\r\n\tkey = key.split ? key.split(\u0027.\u0027) : key;\r\n\tfor (p = 0; p \u003C key.length; p\u002B\u002B) {\r\n\t\tobj = obj ? obj[key[p]] : undef;\r\n\t}\r\n\treturn obj === undef ? def : obj;\r\n}","TestCases":[{"Name":"lodash.get","Code":"var l = _.get(state, [\u0027wrapped1\u0027,\u0027wrapped2\u0027,\u0027location\u0027,\u0027search\u0027]);","IsDeferred":false},{"Name":"Optional chaining (babel es2015)","Code":"var _state$wrapped, _state$wrapped$wrappe, _state$wrapped$wrappe2;\r\n\r\nvar s = state === null || state === void 0 ? void 0 : (_state$wrapped = state.wrapped1) === null || _state$wrapped === void 0 ? void 0 : (_state$wrapped$wrappe = _state$wrapped.wrapped2) === null || _state$wrapped$wrappe === void 0 ? void 0 : (_state$wrapped$wrappe2 = _state$wrapped$wrappe.location) === null || _state$wrapped$wrappe2 === void 0 ? void 0 : _state$wrapped$wrappe2.search;","IsDeferred":false},{"Name":"safeGet","Code":"var l = safeGet(state, [\u0027wrapped1\u0027,\u0027wrapped2\u0027,\u0027location\u0027,\u0027search\u0027]);","IsDeferred":false},{"Name":"dlv (dot notation)","Code":"dlv(state, \u0027wrapped1.wrapped2.location.search\u0027);","IsDeferred":false},{"Name":"dlv (array notation)","Code":"dlv(state, [\u0027wrapped1\u0027,\u0027wrapped2\u0027,\u0027location\u0027,\u0027search\u0027]);","IsDeferred":false}]}