Javascript
```\n/\n * Definition for a binary tree node.\n * function TreeNode(val) {\n *     this.val = val;\n *     this.left = this.right = null;\n * }\n */\n/\n * @par
```\n/**\n * Definition for a binary tree node.\n * function TreeNode(val) {\n *     this.val = val;\n *     this.left = this.right = null;\n * }\n */\n/**\n * @param {number[]} nums\n * @return {TreeNode}\n */\nvar sortedArrayToBST = function(nums) {\n    if (nums == null || !nums.length) {\n        return null;\n    }\n    \n    let mid = Math.floor(nums.length / 2);\n    const node = new TreeNode(nums[mid]);\n    node.left = sortedArrayToBST(nums.slice(0, mid));\n    node.right = sortedArrayToBST(nums.slice(mid + 1, nums.length))\n    return node;        \n};
['JavaScript']