{"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}","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}]}