My gas costs $0.51 per therm, including distribution. When I consume electricity (more on that in a sec) it costs me $0.085 per kWh. On a straight therm to kWh basis, electricity is ahead.
But a single therm is equivalent to 29.3 kWh, so on an energy equivalent basis we've got $2.49 worth of electricity per therm of gas. So for 100% efficient electric radiant heat, electricity is about 5x more expensive than gas. That's close to the efficiency band of an air source heat pump, which tends to run in the 200-300% efficiency range, and geothermal might just beat out gas per BTU transferred into the house, especially if you include hot water consumption in that.
The extra complication is solar. Roof top solar is getting cheaper every single day, and for some of us the effective cost of electricity is $0. If you've got a rooftop solar system it's kind of silly not to switch over to electric heating if possible, since you can get your electricity cheap. Especially if you have net metering or a backup battery. If I didn't have a really high efficiency furnace in my new house, I'd probably have already done that.
That being said, we know that in the long run rooftop solar reduces electricity cost, because otherwise most people would never buy it. From my numbers above rooftop solar only needs to reduce electricity prices by ~40% to put them within striking distance of a heat pump being cheaper than gas.
If you use a heat pump, you might get a COP of 3 or 4, which is effectively 300-400% efficiency. It's able to do this because it makes the outside colder while it makes the inside warmer.
Overall, the electric/heat pump system can be more efficient, but it has a lot more complex and expensive machinery, both in the home and in the power plant, and it's only been in the past 20 years or so that this has been practical. Many new homes are being built without gas hookups and use heat pumps instead.