Recursive and iterative JS versions
Recursive:\n\nvar isSymmetric = function(root) {\n/**\n * Compares two TreeNode\'s\n * @param {TreeNode} root1\n * @param {TreeNode} root2\n * @return {boolean}
Recursive:\n```\nvar isSymmetric = function(root) {\n/**\n * Compares two TreeNode\'s\n * @param {TreeNode} root1\n * @param {TreeNode} root2\n * @return {boolean}\n */\n    function isEqual(root1, root2) {\n        if (!root1 && !root2) return true;\n        if (!root1 || !root2) return false;\n        return root1.val === root2.val\n            && isEqual(root1.left, root2.right)\n            && isEqual(root1.right, root2.left);\n    }\n    if (!root) return true;\n    return isEqual(root.left, root.right)\n};\n```\n\nIterative: \n```\nvar isSymmetric = function(root) {\n    if (!root) return true;\n    \n    const stack = [root.left, root.right];\n    while (stack.length) {\n        const currLeft = stack.shift();\n        const currRight = stack.shift();\n        if (!currLeft && !currRight) continue;\n        if ((!currLeft || !currRight) || currLeft.val !== currRight.val) return false;\n        stack.push(currLeft.left, currRight.right, currLeft.right, currRight.left);\n    }\n    return true;\n};\n```
['JavaScript']