{"ScriptPreparationCode":"var xpath = \u0022/a/b1/c1/d1/../../../b2/c2/d2\u0022\r\nvar xpathParts = xpath.split(\u0022/\u0022);","TestCases":[{"Name":"Reduce (cloning)","Code":"_.reduce(_.clone(xpathParts), function(acc, node) {\r\n if (node === \u0022..\u0022) {\r\n acc.pop();\r\n } else {\r\n acc.push(node);\r\n }\r\n\treturn acc;\r\n}, []);","IsDeferred":false},{"Name":"Reduce (without cloning)","Code":"_.reduce(xpathParts, function(acc, node) {\r\n if (node === \u0022..\u0022) {\r\n acc.pop();\r\n } else {\r\n acc.push(node);\r\n }\r\n\treturn acc;\r\n}, []);","IsDeferred":false},{"Name":"Each (cloning)","Code":"var resultXPath = [];\r\n\r\n_.each(_.clone(xpathParts), function(xpathPart) {\r\n if (xpathPart === \u0022..\u0022) {\r\n resultXPath.pop();\r\n } else {\r\n resultXPath.push(xpathPart);\r\n }\r\n});\r\n","IsDeferred":false},{"Name":"Each (without cloning)","Code":"var resultXPath = [];\r\n\r\n_.each(xpathParts, function(xpathPart) {\r\n if (xpathPart === \u0022..\u0022) {\r\n resultXPath.pop();\r\n } else {\r\n resultXPath.push(xpathPart);\r\n }\r\n});\r\n","IsDeferred":false}]}