The invention provides a water heater and a control method thereof. The water heater comprises a water tank, a compressor, a four-way valve, a coiled pipe, a throttling device, a heat exchanger, an electromagnetic valve, a check valve, a first temperature sensor, a second temperature sensor, a third temperature sensor, a detection device and a controller; the controller is connected with the electromagnetic valve, the four-way valve, the first temperature sensor, the second temperature sensor, the third temperature sensor and the detection device; the opening or closing of the electromagnetic valve or the switching of the four-way valve is controlled by the controller according to the exhaust temperature, the environment temperature, the temperature of the heat exchanger and the operation time of the compressor. According to the water heater, the electromagnetic valve is added, the reversing is not performed through the four-way valve and the heat bypass defrosting is performed when the electromagnetic valve is controlled by the controller to be opened, the four-way valve is energized for reversing and the reverse cycle defrosting is performed when the electromagnetic valve is closed, the two defrosting modes are implemented, and accordingly the loss of the heat is reduced, the defrosting of the water heater can be high in efficiency, and the use comfort of the product is improved.