{"ScriptPreparationCode":"var simpleData = { a: 1 };\r\nvar mediumData = { a: [{ bar: { c: 2 } }] };\r\nvar complexData = { a: [{ bar: { complex: [3, { data: { e: { f: 4 } } }] } }] };\r\n\r\nvar newGet = (obj, path, defValue) =\u003E {\r\n // If path is not defined or it has false value\r\n if (!path) return undefined\r\n // Check if path is string or array. Regex : ensure that we do not have \u0027.\u0027 and brackets.\r\n // Regex explained: https://regexr.com/58j0k\r\n const pathArray = Array.isArray(path) ? path : path.match(/([^[.\\]])\u002B/g)\r\n // Find value\r\n const result = pathArray.reduce((prevObj, key) =\u003E prevObj \u0026\u0026 prevObj[key], obj)\r\n // If found value is undefined return default value; otherwise return the value\r\n return result === undefined ? defValue : result\r\n}","TestCases":[{"Name":"Lodash Get simple data with String","Code":"_.get(simpleData, \u0027a\u0027)","IsDeferred":false},{"Name":"Lodash Get medium data with String and brackets","Code":"_.get(mediumData, \u0027a[0].bar.c\u0027)","IsDeferred":false},{"Name":"Lodash Get medium data with String without brackets","Code":"_.get(mediumData, \u0027a.0.bar.c\u0027)","IsDeferred":false},{"Name":"Lodash Get complex data with String and brackets","Code":"_.get(complexData, \u0027a[0].bar.complex[1].data.e.f\u0027)","IsDeferred":false},{"Name":"Lodash Get complex data with String without brackets","Code":"_.get(complexData, \u0027a.0.bar.complex.1.data.e.f\u0027)","IsDeferred":false},{"Name":"Lodash Get simple data with Array","Code":"_.get(simpleData, [\u0027a\u0027])","IsDeferred":false},{"Name":"Lodash Get medium data with Array","Code":"_.get(mediumData, [\u0027a\u0027, \u00270\u0027, \u0027bar\u0027, \u0027c\u0027])","IsDeferred":false},{"Name":"Lodash Get complex data with Array","Code":"_.get(complexData, [\u0027a\u0027, \u00270\u0027, \u0027bar\u0027, \u0027complex\u0027, \u00271\u0027, \u0027data\u0027, \u0027e\u0027, \u0027f\u0027])","IsDeferred":false},{"Name":"New Get simple data with String","Code":"newGet(simpleData, \u0027a\u0027)","IsDeferred":false},{"Name":"New Get medium data with String and brackets","Code":"newGet(mediumData, \u0027a[0].bar.c\u0027)","IsDeferred":false},{"Name":"New Get medium data with String without brackets","Code":"newGet(mediumData, \u0027a.0.bar.c\u0027)","IsDeferred":false},{"Name":"New Get complex data with String and brackets","Code":"newGet(complexData, \u0027a[0].bar.complex[1].data.e.f\u0027)","IsDeferred":false},{"Name":"New Get complex data with String without brackets","Code":"newGet(complexData, \u0027a.0.bar.complex.1.data.e.f\u0027)","IsDeferred":false},{"Name":"New Get simple data with Array","Code":"newGet(simpleData, [\u0027a\u0027])","IsDeferred":false},{"Name":"New Get medium data with Array","Code":"newGet(mediumData, [\u0027a\u0027, \u00270\u0027, \u0027bar\u0027, \u0027c\u0027])","IsDeferred":false},{"Name":"New Get complex data with Array","Code":"newGet(complexData, [\u0027a\u0027, \u00270\u0027, \u0027bar\u0027, \u0027complex\u0027, \u00271\u0027, \u0027data\u0027, \u0027e\u0027, \u0027f\u0027])","IsDeferred":false}]}