Calculator with Method Chaining Implementation | Dart Solution | Time O(1) | Space O(1)
ApproachThe solution implements a calculator that supports method chaining:

Core Design:

Maintains running result as instance variable
Each operation returns
## Approach
The solution implements a calculator that supports method chaining:

1. **Core Design**:
   - Maintains running result as instance variable
   - Each operation returns 'this' for chaining
   - Final getResult returns computed value

2. **Operations**:
   - Basic arithmetic: add, subtract, multiply, divide
   - Power operation using Math.pow
   - Error handling for division by zero

3. **Method Chaining**:
   - Each method returns calculator instance
   - Allows operations to be chained
   - Maintains state between operations

## Complexity

**Time Complexity**: $$O(1)$$
- All arithmetic operations are constant time
- Power operation using Math.pow is O(1)
- getResult is simple value return

**Space Complexity**: $$O(1)$$
- Only stores single result value
- No additional space needed for operations


# Code
```javascript []
class Calculator {
    /** 
     * @param {number} value
     */
    constructor(value) {
        this.result = value;
    }
    
    /** 
     * @param {number} value
     * @return {Calculator}
     */
    add(value){
        this.result = this.result + value;
        return this;
    }
    
    /** 
     * @param {number} value
     * @return {Calculator}
     */
    subtract(value){
        this.result = this.result - value;
        return this;
    }
    
    /** 
     * @param {number} value
     * @return {Calculator}
     */  
    multiply(value) {
        this.result = this.result * value;
        return this;
    }
    
    /** 
     * @param {number} value
     * @return {Calculator}
     */
    divide(value) {
        if (value === 0) {
            throw new Error("Division by zero is not allowed");
        }
        this.result = this.result / value;
        return this;
    }
    
    /** 
     * @param {number} value
     * @return {Calculator}
     */
    power(value) {
        this.result = Math.pow(this.result, value);
        return this;
    }
    
    /** 
     * @return {number}
     */
    getResult() {
        return this.result;
    }
}
```
['JavaScript']