[JavaScript] O(1) Time For All 3 Operations
Time: O(1)\nSpace: O(N)\njavascript\nclass BrowserHistory {\n    \n    constructor(homepage) {\n        this.history = [homepage];\n        this.curr = 0;\n    
Time: `O(1)`\nSpace: `O(N)`\n```javascript\nclass BrowserHistory {\n    \n    constructor(homepage) {\n        this.history = [homepage];\n        this.curr = 0;\n        this.limit = 0;\n    }\n    \n    visit(url) {\n        this.curr++;\n        if(this.curr == this.history.length) this.history.push(url);\n        else this.history[this.curr] = url;\n        this.limit = this.curr;\n    }\n    \n    back(steps) {\n        this.curr = Math.max(0, this.curr-steps);\n        return this.history[this.curr];\n    }\n    \n    forward(steps) {\n        this.curr = Math.min(this.limit, this.curr+steps);\n        return this.history[this.curr];\n    }\n}\n```
['JavaScript']