Differences compared to the D40
10 megapixel sensor
Lower base sensitivity (ISO 100 vs ISO 200)
Auto ISO option includes ISO 200
Faster continuous shooting (3 fps vs. 2.5 fps)*
* Slower with noise reduction enabled
If you are not shooting for a living, and intend to expand your interest in photography, you may want to consider a 2nd-hand D50 or D80. Or if you are the type who likes to tweak around in PhotoShop, then a D70 will work fine, cheaper too.
D40 has no internal focus motor. Therefore, lenses without focus motor will not be able to AF. If you can do with manual focus, then there will be no limitation.