How Do Vending Machines Detect Fake Coins?

After watching this video on how vending machines can detect fake coins I am blown away. Because I have always wondered how the machines work. Well we know that you put money in and press buttons to get your food. But there is more to them than just doing that.

I will never forget the days of paying for your snack and it not coming out and or it would get stuck right at the edge.