Having batteries may or may not help depending on the load you wish to power, how long you wish to power it, how frequently you wish to power it and how much you want to spend.
My parents have a beach hut in which they use solar.
There is a 100W panel charging two 150Ah batteries through a charge controller. This powers 50W 12V halogen lights, a 250W inverter, water pump for the tap and fan in a caravan style gas heater.
They don't bother with deep cycle/superior quality batteries any more as they found the cost premium wasn't worth it based on their usage over the years.
As an example lets say:
1) Your solar panel provides its full 40W for 8 hours a day. At a guess possible in the height of summer but not for the rest of the year.
2) The system efficiency of the battery and charging controller is 60% (
source)
3) Your inverter is 90% efficient (
source)
The panel delivers 40W * 8 hours = 320 Watt hours per day
320Wh * 60% efficiency = 192Wh available to your inverter
192Wh * 90% efficiency = 173Wh available to whatever you are powering.
173Wh / 300W = 0.68 hours or 35 minutes.
According to these figures your solar panel could power your 300W load for 35 minutes a day.
If you only wanted to use it once per week and had big enough batteries you could charge for 6 days then get 3.5 hours use on the 7th.
These efficiency figures may or may not be realistic and I have no idea what fraction of its peak power a solar panel produces over an average day. I just pulled some figures out of google searches.
To put it another way your 300W load is 7.5 times larger than your 40W supply (300/40=7.5). This means you need to supply 40W for 7.5 hours to power your 300W device for 1 hour. This is before taking into account any of the losses I listed above.